Issue with Excel Pivot Table Subtotals / Row Hierarchy - excel

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.

Related

how to merge data from several tables in a pivot table

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.

Pivot Table Excel Grand Total Shows the Sum of Unformulated Calculated Field Value

I tried a simple data table,
Table 1
ITEM
TARGET
A
150
B
150
Table 2
ITEM
PROD_QTY
A
160
B
120
I append both of the tables and create a Pivot Table, then use calculated field to see the outstanding by using these formula:
=IF(TARGET-PROD_QTY<=0;0;TARGET-PROD_QTY)
It worked well with the sum of outstanding, but when I was see the grand total, it shows like this:
ITEM
SUM OF OUTSTANDING
A
0
B
30
Grand Total
20
Is there anything that I could do to fix the grand total?
Cause I think the Grand Total is ignoring the =IF function in Calculated field and just go straight to the calculation

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]))

Calculate percentage in Excel pivot table

I have an Excel table with country, ID & group columns.
I created a pivot table with countries in rows, groups in columns and
the values are count of ID's in each country/group.
I wish to add to the pivot percentage columns for each group.
It should display the percentage of the total in the source table.
If I hide some groups/countries then the total percentage will not be 100%.
I tried to add calculated field in which I divide the count of ID's to total ID's
but it did not work.
How can I do it ?
Thank you
Example File

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

Resources