Pivot Tables are notorious for not having "that one obvious feature".
In this case, the "aggregate of the calculation" (e.g. sum of %Used) should really be the "calculation of the aggregate" (e.g. %Used of the sums). Unfortunately, there doesn't seem to be a way to coerce this out of the pivot table.
As a fallback position, you can use VBA.
- In the VBEditor, double click the worksheet containing the Pivot Table
- In the first drop down, select Worksheet.
- In the second drop down, select PivotTableUpdate
Insert the following code for the PivotTableUpdate event. It should work cleanly for many kinds of changes - I am sure there will be cases that I haven't dreamed up ...
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim rCell As Range, rCol As Range, rRow As Range
Dim lNewCol As Long, lBudgetCol As Long, lSpendCol As Long, lRow As Long
Dim sFormula As String
' Initial
Application.ScreenUpdating = False
' Clean up remnants of old calculation
For Each rRow In ActiveSheet.UsedRange.Rows
For Each rCell In rRow.Cells
If InStr(rCell.Formula, "=") Then
rCell.Delete shift:=xlShiftToLeft
GoTo NextCell
End If
If rCell.Value = "%Used" Then
rCell.Columns(1).EntireColumn.Delete shift:=xlShiftToLeft
GoTo NextCell
End If
If rCell.Value = "Budget" Then lBudgetCol = rCell.Column
If rCell.Value = "Spending" Then lSpendCol = rCell.Column
NextCell:
Next rCell
Next rRow
lNewCol = ActiveSheet.UsedRange.End(xlDown).End(xlToRight).Column + 1
' Implement new calculation and format
For Each rRow In ActiveSheet.UsedRange.Rows
lRow = rRow.Rows(1).EntireRow.Row
ActiveSheet.Cells(lRow, lNewCol - 1).Copy
ActiveSheet.Cells(lRow, lNewCol).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
If lRow = 4 Then ActiveSheet.Cells(lRow, lNewCol).Value = "%Used"
If lRow > 4 And IsNumeric(ActiveSheet.Cells(lRow, lNewCol - 1).Value) Then
sFormula = "=R" & lRow & "C" & lSpendCol & "/R" & lRow & "C" & lBudgetCol
ActiveSheet.Cells(lRow, lNewCol).FormulaR1C1 = sFormula
ActiveSheet.Cells(lRow, lNewCol).Style = "Percent"
End If
Next rRow
' clean up
ActiveSheet.UsedRange.End(xlToLeft).Select
Application.ScreenUpdating = True
End Sub
The formula used to calculate %Used is (for example) =C5/B5
as opposed to =GETPIVOTDATA(...)/GETPIVOTDATA(...)
for simplicity.
The following screenshots show results as filters and layout are modified ...
![enter image description here](https://i.stack.imgur.com/CaU9g.png)
![enter image description here](https://i.stack.imgur.com/jIe8C.png)
![enter image description here](https://i.stack.imgur.com/ntugX.png)
![enter image description here](https://i.stack.imgur.com/Dqjwx.png)