Power Pivot Sum across factTables - excel-2010

I'm having trouble creating a sum across multiple factTables in Power Pivot for Excel 2010.
Here's a simplified layout.
Network A - Date, Product Name, Revenue
Network B - Date, Product Name, Revenue
Network C - Date, Revenue
dimCalendar
They are all related via dimCalendar. Network A and B have multiple products that are unique to each network.
Each network has a measure to sum its revenue, for example:
Network A - Revenue:=SUM([Revenue])
I have created a Pivot Table that has columns for each network's revenue and rows for the date. How can I add a column to the Pivot Table that calculates total revenue across all ad networks per day?

Gee, I must have had a brain cramp yesterday! Here's my solution:
Total Revenue:=Calculate([Network A - Revenue] + [Network B - Revenue] + [Network C - Revenue])

Related

How to find balance stock cost of SKU based on received date?

Above is an example of data in Google Sheets. The green table is to keep track my purchases and the red table is to show the inventory summary.
I am stuck at creating a formula to calculate the Balance Stock Cost.
The Balance Stock Cost should only sum up the cost of unsold quantity from latest received date.
For example, for SKU A, the stock balance is 31 units. The purchases of SKU A sorted by received date will become like this...
Since the stock balance is 31, the formula should sum up the purchases on 10-Jan (5 units x 6), 7-Jan (25 units x 4) and 5-Jan (1 unit x 5.5) which brings the total to 135.5.
Please help me to come up a formula to calculate the Balance Stock Cost based on above requirements. Thanks.
You can try:
=MAP(A18:A,D18:D,LAMBDA(ax,dx,IF(ax="",,SUM(QUERY(SORT(ARRAYFORMULA(split(flatten(A2:A15&"|"&B2:B15&"|"&D2:D15&"|"&MAP(C2:C15,LAMBDA(cx,TRANSPOSE(SEQUENCE(cx,1,1,0))))),"|",0,0)),1,1,2,0),"Select Col3 Where Col4 is NOT NULL AND Col1='"&ax&"' LIMIT "&dx)))))

Using Sumifs, where a range can match multiple criteria

I have 2 sheets in Google Sheets:
All contacts w. week/month/year, where we pull all of our deals for the year
Weekly Marketing analytics, where we match up all of this information on a weekly basis
In the Weekly Marketing analytics, every column from B2 to BB2 is a week number (1-53), and A1 is the current year (2021 with this sheet).
I am currently trying to find and sum, every deal value on a 10 week running average (week 1-10, 2-11 etc.) and in order to do that, I've created this formula:
=SUMIFS('All contacts w. week/month/year'!$D:$D;'All contacts w. week/month/year'!$T:$T;$A$1;'All contacts w. week/month/year'!$Q:$Q;C$2:L$2; 'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH")
'All contacts w. week/month/year'!$D:$D - This is the column with all of the revenue for a given deal.
'All contacts w. week/month/year'!$T:$T;$A$1 - This is the column with the year of the deal.
'All contacts w. week/month/year'!$Q:$Q;B$2:K$2 - This is the column I am having trouble with. This is the column with the week number of the deal, and since I am doing a 10 week running average, I want every deal for the last 10 weeks. So all deals from week 1, 2, 3 etc that matches all of the other criteria.
'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH" - This is the last criteria, defining which marketing channel the deal originated from.
Currently this formula returns 0, despite there being a deal in week 4, and I cant work out why the system is missing it?
In the bigger picture, this is the for I want to end out with:
=IF(SUM(C$116:L$116)>0;SUM(SUM(C$143:L$143)/SUMIFS('All contacts w. week/month/year'!$D:$D;'All contacts w. week/month/year'!$T:$T;$A$1;'All contacts w. week/month/year'!$Q:$Q;C$2:L$2; 'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH")); 0)
Quickly checking if there is any deals counted in those weeks, if yes then sum up the marketing cost for a given channel, divided with the revenue of the deals for those given weeks.
It's hard to say without seeing the actual data, but it looks like the Criteria2 argument is problematic, because C$2:L$2 is really an array of criteria. So depending on your version of Excel, it would return either a spilled array or the first element of the array (basically only using C$2 as a criteria.)
If the week numbers are numeric (1,2,3 etc.) instead of text (Week1, Week2, Week3, etc.) then you ought to be able to break it out into 2 criteria using inequalities. For example, suppose L2 is week 11. That means the expression L2-9 provides your lower bound of 2. So in your SUMIFS function you should sum everything greater than or equal to L2-9 AND less than or equal to L2.
Your formula might look something like this:
=SUMIFS('All contacts w. week/month/year'!$D:$D;'All contacts w. week/month/year'!$T:$T;$A$1;'All contacts w. week/month/year'!$Q:$Q;">=" & L2-9; 'All contacts w. week/month/year'!$Q:$Q; "<=" & L2; 'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH")

Google Sheets Pivot Table - Show dates in between

I have a pivot table with the cumultative number of shares for each stock and with different timestamps when a portfolio-change was made (invest or divest):
https://docs.google.com/spreadsheets/d/1IxdeBriRA9DgVclAWwfrz5ni1bZO94xwh0jFCghTLDg/edit?usp=sharing
Now I want to add the dates 'in between' (for every single weekday) the invest and the divest timestamps, where logically the cumultative numer of shares are more than zero.
Example 'Apple': I want the pivot table to show all the dates for every single weekday for Apple from 2013-05-08 to 2014-12-16 with the cumultative num of shares.
Example 'AT&T': Because there is no divest of AT&T Stocks, I want all the dates from 2020-04-06 to today.
I'd like to have this two examples with all the other stocks in one table to apply further functions. The purpose is to use the GOOGLEFINANCE function for the stock prices for each single day afterwards. But first, I need all the dates (where the number of shares is >0).
In the second sheet are the 'raw data'. I'm also fine if there is a better solution than using pivot table.
Thank you very much!
Greets Fabian
Please, see testFile.
Since your data contains large period of time, table with all dates included for all stocks would be really big and unusable so suggest to select one stock and create table for it.
Thus on testSheet in cell B1 you select stock name you are interested in.
In cell B2 select whether you want period for only historic data or up to date.
Following formula creates sequence of dates starting from first date for selected stock and up to date.
=ARRAYFORMULA(
IF($B$2="Today";
SEQUENCE(TODAY()-MIN(FILTER('Stock Track Record'!A:A;'Stock Track Record'!F:F=$B$1))+1;1;
MIN(FILTER('Stock Track Record'!A:A;'Stock Track Record'!F:F=$B$1));1)))
Then next formula gets values from your initial data.
=ARRAYFORMULA(
IFERROR(VLOOKUP($A$5:$A;
QUERY({'Stock Track Record'!$A:$F};
"Select Col1, Col2, Col3, Col4
Where Col6 = '"&$B$1&"'";0);2;0);""))
And following calculates cumulative number of shares:
=ARRAYFORMULA(IF(A5:A="";"";SUMIF(A5:A;"<="&A5:A;D5:D)))

Combining the select clause in query function with Indirect function. - Google Spreadsheets

So basically I need a dynamic select statement which changes references when dragged across rows or columns.
Example of what I need.
=sum(query('Sheet1'!$A$1:$F$621, Indirect("Select"&$F&"Where A='ABC' AND B="&"Sheet2!"&$A1)))/20
Sample Sheet 1 (Data Sheet)..--Since I am not allowed to use images till i reach rep 10 lol :)
Column 1 - Sales Sites (ABC, DEF, GHI.....)
Column 2 - Sales Roles (SM, ASM, SE.....)
Column 3 - Sales in Month Jan
Column 4 - Sales in Month Feb
Column 5 - Sales in Month Mar
Sample Sheet 2 (Desired Output)
Description (in pivot terms):
Site wise (filter)
Role wise (Rows)
Month wise (Columns - Sum of Jan, Feb etc)
Value (Sum of Jan/20)--To get day wise sales numbers
FYI:
I have tried using pivots, but google spreadsheets don't allow use of calculated fields in pivots in any manner (for the /20 in the formula), hence trying to achieve the same results by formula.
I know a table on the basis of the pivot table could help solve this problem, but to make it more efficient I am trying to avoid using 2 tables.
Many Thanks for your help in advance, please let me know if you need additional info to understand the scenario.

Query for SUM values on multiple columns, then substract and compare results

I have the following scenario:
A Google Sheet to collect daily Cash Flow on two shifts (Morning and Afternoon), starting each shift with money on hand (cash) and money on bank account (to pay bills and make transfers as necessary).
The circuit works by recording money IN or money OUT and using the direction of the flow as a basic selector, in order to determine by adding and substracting, how much money came in, and how much came out.
I've been testing with long QUERY formulae to try to come out with results, but so far, I managed to only filter by means of SUM(X). However, I been trying after reading all documentation about Query Formula, to select and sum every income for every shift within the day, do the math, compare with the starting cash, and determine how much money by means of payment, date and shift came in or out.
This is the Query formula for the collected items:
=QUERY(A1:Q,"SELECT A,B, SUM(G), SUM(H), SUM(I), SUM(J), SUM(K) WHERE E='Collected' AND L='Cash' GROUP BY A,B LABEL SUM(G)'Rentals Collected' ",2)
And this is the Query formula for the paid items:
=QUERY(A1:Q,"SELECT A,B, SUM(G), SUM(H), SUM(I), SUM(J), SUM(K) WHERE E='Paid' AND L='Cash' GROUP BY A,B LABEL SUM(G)'Rentals Paid' ",2)
I've also used this Query formula for displaying money available on hand at the start of each shift, for each day.
=QUERY(A:Q, "SELECT A,B,C,D WHERE C IS NOT NULL", 2)
Any ideas?
Here's a Dummy Sheet that recreates the scenario.

Resources