Calculate Percentages on Excel Pivot Table Totals - excel

I have Excel source data with Phase, Team, and Early or Late. I've created a pivot table to summarize the data like this:
Team 1 | Team 2 |
Phase Early | Late | Total | Early | Late | Total | Grand Total
---------------------------------------------------------------------
Phase 1 2 3 5 0 1 1 6
Phase 2 4 5 9 2 2 4 13
Phase 3 5 6 11 1 1 2 13
Grand Total 11 14 25 3 4 7 32
I'd like to calculate percentages of the totals (so the total early for team 1 divided by the total for team 1--or 11/25 for 44% early, and then the total late divided by the total, or 14/25 for 56% late).
I tried using formulas below the pivot table, which worked great, but they get out of whack if the source data doesn't have records that fall in a column (so if there are no late items for Team 2, that column disappears). Is there an easy fix or a way to keep the pivot table at a set number of rows or columns?

Instead of constructing formulas separately from the pivot table you can just set the pivot table to calculate the percentages directly. That way you don't have to worry about how many columns and rows are in the pivot table. In Excel 2010 (2007 s/b the same too) go to the PivotTable Tools ribbon then options and under calculations click the dropdown Show Values As and select % of Parent Column Total.

Related

DAX for MAX of a group

I have two data columns:
Record | Record Version
------------------------
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
2 | 3
2 | 4
3 | 1
3 | 2
3 | 3
4 | 1
4 | 2
4 | 3
4 | 4
4 | 5
4 | 6
5 | 1
6 | 1
Is it possible to create a calculated column within a MVS-2012 model or PowerPivot that will give the MAX of the Record Version for a corresponding Record? For example the MAX value of Record 1 is 3, MAX value of Record 2 is 4 etc.
Yes. Add that table to your Power Pivot model, either by pasting the data into Excel and then clicking Add to Data Model on the Power Pivot ribbon, or by opening the Power Pivot Window and adding it form it's original source there.
In the Power Pivot window, go to the table where this data is located.
Select the Record Version column, then click the drop-down next to AutoSum in the Calculations group on the Home tab and choose Max.
A calculated column will appear at the bottom. YOu can rename it to something like Max Record Version.
Make a PivotTable in Excel (click the PivotTable button on the Home tab).
Add the Record field to rows and the Max Record Version to values.
If you actually want a calculation that will give you the max for the group of record you could do something like:
=SUMX(VALUES(Table1[Record])
,CALCULATE(MAX(Table1[Record Version]))
)
Generally, as #mmarie suggests, you are better dealing with this kind of problem with a measure rather than a calculated column. That said, sometimes you just need that extra column (usually to use as a dimension).
Assuming you have a table called recordsFact, this gives the MAX of that record:
= CALCULATE(MAX(recordsFact[Record Version]),
FILTER(recordsFact, recordsFact[Record] = EARLIER(recordsFact[Record])
))

Removing Excel Pivot-table columns but retaining grand total

I'm using Excel pivot-tables to produce a report. The pivot-table connects to a SSAS cube. I have 2 measures- measure 1 is a 'real' measure, measure 2 is calculated based upon measure 1. Measure 1 must be shown broken out by dimB members across the columns. WIth Measure 2 I just want the totals column.
I've hidden the measure 2 columns as a workaround but this is less than ideal as when users expand or contract the dimension B members the pivot-table moves relative to the hidden columns and the report becomes a mess. It's also returning extra data which can't help performance.
Here is what I have:
Measure 1 Measure 2 Measure 1 Total Measure 2 Total
a b c a b c
DimA- member1 2 3 4 2 3 4 9 9
DimA- member2 1 4 5 1 2 5 10 8
This is what I want:
Measure 1 Measure 1 Total Measure 2 Total
a b c
DimA- member1 2 3 4 9 9
DimA- member2 1 4 5 10 8
Is there a way to achieve the second option? Either with perhaps some mdx on the calculated measure (scope/custom rollup etc) or with the pivottable itself?
Basically I want the total without the dimension B breakdown for measure 2.
I don't know that technique, and afraid, that it's impossible.
What if to NULLify all members in scope at least for the lowest levels?
Something like this:
SCOPE ([Measures].[Measure 2 Hide]);
THIS = IIF(Axis(1).Item(0).Item(0).Hierarchy.Level.Ordinal=1
,[Measures].[Measure 2],null);
END SCOPE;
Or <2 instead of =1. Measure 2 will be at least empty for users.
Here is my Excel example (measure is called Measure 2 Hide):
CREATE MEMBER CURRENTCUBE.[Measures].[Measure 2 Hide]
AS
[Measures].[Count]-1,
VISIBLE = 1;
I understand that it's not a solution, but maybe will help somehow.

2 subtotal lines showing on excel pivot table

I have an Excel pivot table which summarises values using the MAX function. I've set the row subtotal to SUM the max values and display it at the top of each group.
For some reason I still get a subtotal which shows the max for each group as well and I cant turn it off.
Table shows something like
Category Customer 1 Month 3 Months 6 Months
Customers 1 1 1
Customers 1018 4726 10511
Customers over £10,000 1 1 1
Customers over £10,000 26 237 542

Grand total for pivot table not giving me the correct amount when using a calculated field

I have a pivot table that I put a calculated field in. the calculation is =IF(fddue_date<finspectData,0,COUNT(fLotSize))
The problem is that instead of getting the expected result of 6 I get 1. Any one have an idea what I am doing wrong?
Row Labels Count of fLotSize Sum of Field1
5/14/2014
5/12/2014 1 0
5/14/2014 7 1
5/15/2014 9 1
5/16/2014 5 1
5/19/2014 3 1
5/30/2014 1 1
6/9/2014 1 1
Grand Total 27 1
This is a side effect of the calculated field and it treats the grand total the same way as any other row in the pivot table.
If you want to use this type of calculated formula and have a sum shown in the grand total, the best way is to create the formula in the source data table and then pull it into your pivot table as a separate column which will show the correct grand total.
it's by the way a known bug since at least Excel 2003. still in 2013 ...
https://support.microsoft.com/en-us/kb/211470

Custom Formula for Grand Total column

I have a frequent problem where the formula I want to use in the Values area in my Pivot-Table is different than the formula I want to use for the Grand Total column of that row. I typically want to Sum the Values but I want to average the Sums. Here is what I normally would get if I pivoted the dates on the Column Labels, Meat Type on the Row Labels, and Sum Orders in the Values.
Row Lables | Day 1 | Day 2 | Day 3 | Grand Total
________________________________________________
Beef | 100 | 105 | 102 | 307
Chicken | 200 | 201 | 202 | 603
I get sums by day and a sum of all of the days in the Grand Total column. Here is what I want to have:
Row Lables | Day 1 | Day 2 | Day 3 | Grand Total (Avg of Day Totals)
________________________________________________
Beef | 100 | 105 | 102 | 102.3
Chicken | 200 | 201 | 202 | 201.0
In this case the Orders are still summed by day but the Grand Total is now an average of the sums. What I do now is copy and paste the Pivot data onto a seperate sheet then calculate the averages. If there was a way to do this with a custom Grand Total column it would be incredible. This is one of the biggest shortcomings of Pivot Tables for me but I'm hoping it is due to my ignorance, which it often is. Thanks for the help!
You can write a measure that checks the number of 'rows' in a particular filter context and nest that in an IF() to determine which to use.
If using PowerPivot V2 then it's:
=IF(HASONEVALUE(Calendar[Day]), SUM(AMOUNT), AVERAGE(AMOUNT))
If using PowerPivot V1 it's:
=IF(COUNTROWS(Calendar[Day])=1, SUM(AMOUNT), AVERAGE(AMOUNT))
Both do the same thing in that they assess the number of rows in the table in the given context and when the Meat Type is 'Beef' then the temporarily filtered table has one row. If it doesn't have one row then its going down the path of the AVERAGE()
This assumes your column headers 'Days' are in a table called Calendar (if you aren't using a separate Calendar table then you are missing the most powerful functionality of PowerPivot IMO).
Jacob
I can't think of a "good" way, but here's one option. Add the Amount field to the data area a second time and change the operation to Average. Then use conditional formatting to hide the averages in the data area and hide the sums in the total area.
You might be better off just using some array formulas in a do-it-yourelf pivot table. You lose the pivot table benefits, but get more flexibility with the data.

Resources