Using GETPIVOTDATA on custom group subtotals

miconian

Well-known Member
Joined
Aug 18, 2004
Messages
769
I have two perfectly functional formulas that pull data from a pivot table. I want a formula that actually just adds those two numbers together

The working formulas I have are:

Code:
=GETPIVOTDATA("total_imps",C87,"site_rollup","cbs","platform_type","Desktop","ad_grouping","Native Slot - Native Served","month_id",'F5 2016 new'!X1)
=GETPIVOTDATA("total_imps",C88,"site_rollup","cbs","platform_type","Desktop","ad_grouping","Native Slot - Non Native IAB Standard Served","month_id",'F5 2016 new'!X1)

The important part here is the group called "ad grouping." You can see that the only difference between the formulas above is that they each reference a separate item within "ad grouping."

I was thinking that instead of making an unwieldy SUM to combine the two formulas above, I would create a new custom group that combines the two "ad_grouping" items. I created it. The new group is called ad_grouping2, and the new item is called NativeSlotTotal.

But I have not been successful in referencing that new grouping with a formula. Here is something I tried:

Code:
=GETPIVOTDATA("total_imps",C88,"site_rollup","cbs","platform_type","Desktop","ad_grouping2","Native SlotTotal","month_id",'F5 2016 new'!X1)

This returns #REF.

So I found this old article[url] about solving the problem in Excel 2003. I am using Excel 2016, but it seemed like the same problem. So, going with the recommendation in that article, I tried this:

Code:
=GETPIVOTDATA("total_imps",C88,"site_rollup","cbs","platform_type","Desktop","ad_grouping2"["ad_grouping2";SUM],"Native SlotTotal","month_id",'F5 2016 new'!X1)

The key part of the above being:
Code:
"ad_grouping2"["ad_grouping2";SUM],"Native SlotTotal"[/]
Where I was attempting to imitate this:
[code]  GETPIVOTDATA(<AnchorCell>,"<GroupName>[<GroupItem>;<FunctionName>]")

But Excel doesn't even recognize that as a formula.
Any thoughts on what I'm doing wrong?

I also tried this as an array:

Code:
=GETPIVOTDATA("total_imps",C88,"site_rollup","cbs","platform_type","Desktop","ad_grouping","{"Native Slot - Native Served","Native Slot - Non Native IAB Standard Served"},"month_id",'F5 2016 new'!X1)
But Excel doesn't seem to like the dashes there, which it treats as minus signs.

Many thanks.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I was thinking that instead of making an unwieldy SUM to combine the two formulas above, I would create a new custom group that combines the two "ad_grouping" items. I created it. The new group is called ad_grouping2, and the new item is called NativeSlotTotal.

But I have not been successful in referencing that new grouping with a formula. Here is something I tried:

Code:
=GETPIVOTDATA("total_imps",C88,"site_rollup","cbs","platform_type","Desktop","ad_grouping2","Native SlotTotal","month_id",'F5 2016 new'!X1)

This returns #REF.

I think this should have worked unless you have a name mismatch (e.g. "Native SlotTotal" vs. "NativeSlotTotal"). Try letting Excel generate the GetPivotData formula for you by selecting a cell outside the Pivot, entering "=" (without quotes), then selecting that grouped subtotal PivotItem.

You'll need to have the default option checked if it isn't already: File > Options > Formulas > Working with formulas > Use GetPivotData functions for PivotTable references.

If you would rather not use Grouping to accomplish your Summing, you could use an array formula like this (confirmed with ctrl+shift+enter not just enter):

Code:
=SUM(IFERROR(GETPIVOTDATA("total_imps",C87,"site_rollup","cbs","platform_type","Desktop","ad_grouping",
   "Native Slot - " & {"Native Served","Non Native IAB Standard Served"},"month_id",'F5 2016 new'!X1),0))
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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