how to merge data from several tables in a pivot table - excel

I want to create an overview monthly report for all the data in the worksheet. So for June, I'll see the sum of expenses, and sum of revenue, each existing in different tables.
Expense
Date
Price
expense 1
22/06/2022
100
expense 2
25/06/2022
120
expense 3
07/07/2022
60
Revenue
Date
Amount
Salary
11/06/2022
150
Interest
01/07/2022
20
Desired result
Month
Expenses
Revenue
06-2022
220
150
07-2022
60
20
(I have a helper column month which converts date to a string month in the m-yyyy format)
I added all the tables to a data model, and created a pivot table from the data model. My problem, is that even though each table has the hidden "month" field, e.g. 06-2022, for a "row" I have to select a month field from a specific table, and then other table does not break down for that month. And if I select both month fields for the pivottable row, I just get nested data.

Well, I was able to solve it, but I am not sure my answer is ideal, so I'll accept other answers.
I used Power Query. I created queries from each of the source tables, removing most of the columns, and keeping only date and price. I renamed the price column "revenue" for both source tables, and I multiplied the price (now renamed revenue) of the expenses table by -1, since its function is to decrease revenue.
I then joined the two queries into a new query, removed the "day" part of the date by using the "begining of month transformation on the new query". Then I grouped all the rows by date, using the sum function on the revenue column. I saved the new query.
Then I created a relationships between the month of the query, and the month field of the expense table. I did the same for income table.
Finally, I was able to create a pivot table from the data model, with the month of the month query as rows, sum of expense price column, sum of income amount column, and sum of (but it's only one value anyway) month's query revenue column.
This works, but is slow, needs manual refreshing, and causes "foreign data" alerts in excel.

Related

Excel: Extracting data based on range

I have a table for the number of products sold:
I have another table that calculates the cumulative product sold
I have a price table based on # of product sold:
What equation should I write to get the cost price of the product based on cumulative data? Basically, as the cumulative product for category A is less than 10 till 2022 the multiplier price is $5 but in 2023 as the cumulative product is more than 10 the multiplier is $3.
Please know that the actual data set has a price multiplier for multiple range and the number of products sold is in million. The above is just a sample.
Lose the < character in the Item column of the price table. Then you can use it for an approximate lookup.
Let's say the price table is on a sheet called PriceSheet and starts in cell A1, so the first row of data is in row 2. The price table must be sorted ascending by the first column. To look up the price use
=vlookup(A1,PriceSheet!$A$2:$B$5,2,1)
Multiply that with the count.
=A1*vlookup(A1,PriceSheet!$A$2:$B$5,2,1)
Now just change A1 to the cell that has the cumulative count.

Pivot Table Sum Items, But Average Grand Total

I have a Standard Pivot Table it has Date from the Columns and Numbers in the Value,
Column: Date | Numbers
I want the Numbers in the Rows to be Calculated as Sum, but I want the Grand Total to Average those Sums Rows
How is this possible?
Assuming you have PowerPivot, which you should if you have 2016, and assuming a table called Table1 loaded into the data model, you can add a measure for the sum, called say TotalNumber, which is just:
=SUM(Table1[Numbers])
Then add another measure which is the one you'll use in the pivot table:
=IF(HASONEVALUE(Table1[Date]),[TotalNumber],averagex(VALUES(Table1[Date]),Table1[TotalNumber]))

Compare column value with series of auto sum value in Power Pivot?

I have problem where i need to get the number of weeks after which my stock will run-out.
In my table i have:
"Forecast Regulier calc." which is the total sales.
And the auto generated total is the project stock.
Each value of "Forecast Regulier calc." in column is the sales on that particular week. Now the goal is to compare the sales of each week with the series of all auto generated total values and get the difference in column values where the two values match. And this will be the number of weeks after which our stock will run-out.
Please let me know if the description is not clear.
.

creating a calculated field in excel pivot table based on an item in a column

Normally calculated pivot table fields in excel (2010) you click:
design tab > options and sets > calculated field
and if you had three columns: name, sales, cost
name | sales | cost
josh 10 2
your calculated field might be: profit which would be: = sales - cost.
However is it possible to make a calculated field which calculates the difference between two items in the one "Week Ending" column?
For example "Week ending" contains a dates which end on a friday 2015-05-01,2015-05-08,2015-05-15 etc and they are in the column labels section of the pivot table.
The "week ending" dates are all in the one column, is it still possible to calculate the difference between two of them with a calculated field?
name | End Fri 2015-05-01 | End Fri 2015-05-08 | calculated (Delta)
josh 8 10 10-8 = 2
You do this with a Calculated Item. Here is an example that I think gets close to what you want. I selected one of the dates in order to get the menu to show up.
Here is the result
And here is a good reference about these. http://www.contextures.com/excelpivottablecalculateditem.htm

Issue with Excel Pivot Table Subtotals / Row Hierarchy

I currently have a pivot table with three row labels. The data in the row labels is grouped as follows:
Customer SKU Grouping YTD PrevYTD
123 ABC Qty 30 20
Sales 500 400
DEG Qty 100 150
Sales 1,000 2,000
The YTD and PrevYTD are columns and the values.
I can do a custom subtotal on the 'Grouping' field and choose Sum and it gives me the totals at the end of the report:
Qty Sum 130 170
Sales Sum 1,500 2.400
This is good to this point, but I also want to have subtotals by customer. What I want to see is the same breakdown under each customer (a total of Qty and a total of Sales) but I cannot get this subtotal to work. When I put a subtotal on the Customer field, it puts a oneline subtotal and is adding the Qty and the Sales together. In this example if I put a subtotal on Customer This is what it will display:
123 Total 1630 2570
Is this possible to do what I am looking for?
Thanks for the help!
How about making Grouping a column label instead? It will change the layout somewhat but will allow you to get the effect you are after.
To do this you need to use a second pivot table. It's easier to do it with the tables side-by-side, but you can do it with a table underneath by just deleting the second table and inserting a new pivot table after the last row of the first each time the first table is changed.

Resources