Calculate Percent of Subtotal In Pivot Table

dcoons

Board Regular
Joined
Apr 21, 2002
Messages
56
Hello,

It does not appear that subtotal percentages are possible in a pivot table using a calculated field. Is this true? (If so, what a glaring oversight by Microsoft). I've tried a variety of options, none of which produce the desired result, which is a subtotal percentage that adds to 100 percent and will recalculate as the table is changed. This seems to be a fairly common problem (without a solution!) judging from the posts I've seen

I have been able to successfully use Andrew Poulsom's great formula solution found elsewhere in this forum. It is a good solution for tables where all possible values for a subtotal will always be used, but it does not adjust/recalculate if the pivot table changes (in the example below, if one were to exclude TV, the subtotals in Chicago, for example, would not recalculate so that the market total for the remaining Internet and Radio would remain 100%)

Is there a way to do this with a calculated field, or a way that will adjust if a member of the subtotal is excluded?

Note in the image below, the pivot table "Amt" column comes from the Amout column in the spreadsheet, and the pivot table "Pct Mkt" is the sum of the "MktSubTotForm" column (uses Andrew's formula) in the spreadsheet side. This is the column I would like to replace with a calculated field or some other 'adjustable method' if there is one.

Thanks for looking,
Dale.
Book1
ABCDEFGHI
1MarketMediumAmountMktSubTotFormData
2ChicagoInternet243.31MarketMediumAmtMktPct
3ChicagoInternet24033.06ChicagoInternet26436.4
4ChicagoRadio223.03Radio24233.3
5ChicagoRadio22030.30TV22030.3
6ChicagoTV202.75ChicagoTotal726100.0
7ChicagoTV20027.55LosAngelesInternet38546.7
8LosAngelesInternet354.24Radio27533.3
9LosAngelesInternet35042.42TV16520.0
10LosAngelesRadio253.03LosAngelesTotal825100.0
11LosAngelesRadio25030.30NewYorkInternet33050.0
12LosAngelesTV151.82Radio22033.3
13LosAngelesTV15018.18TV11016.7
14NewYorkInternet304.55NewYorkTotal660100.0
15NewYorkInternet30045.45GrandTotal2211300.0
16NewYorkRadio203.03
17NewYorkRadio20030.30
18NewYorkTV101.52
19NewYorkTV10015.15
Sheet1
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You could try this formula in D2 copied down:

=IF(ISNUMBER(MATCH(B2,G:G,FALSE)),C2/SUMPRODUCT(--(A$2:A$19=A2),--(ISNUMBER(MATCH(B$2:B$19,G:G,FALSE))),C$2:C$19)*100,0)

Note that you will need to refresh the pivot table after you change what's shown in the Medium field, because the formula refers to that column. You could use the Worksheet_Calculate event procedure to automate it:

Code:
Private Sub Worksheet_Calculate()
    Application.EnableEvents = False
    Me.PivotTables(1).PivotCache.Refresh
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top