Help with GETPIVOTDATA formula

ExcelAtEverything

Active Member
Joined
Jan 30, 2021
Messages
351
Office Version
  1. 2019
Platform
  1. Windows
I feel like I am having a senior moment here, and could sure use some assistance.
I cannot for the life of me get this simple GETPIVOTDATA reference to become dynamic.

In the Pivot Table below, the "Primary Categories" are items like basketballs, baseballs, footballs, soccer balls, etc. As it is, each day column C shows the top category for each Org #, and column D shows the dollar amount for that top category (for each Org #). That Org # list will grow as time goes on, and the "Primary Category" will be one of maybe 15-20 different categories that is showing here.

In this formula designed to reference D5 below, the "baseballs" part is what I can't seem to make dynamic. (Assume the catg "Baseballs" is what is showing in C5).
=GETPIVOTDATA("[Measures].[Sum of Inventory Value]",'Biggest Aging Category'!$B$4,"[Current Inventory Report].[Org #]","[Current Inventory Report].[Org #].&[" &[@[Org '#]]& "]","[Current Inventory Report].[Primary Category]","[Current Inventory Report].[Primary Category].&[Baseballs]")

Additionally, when I try to grab the GETPIVOTDATA formula for "Baseballs" in C5, all I get is this: ='Biggest Aging Category'!C5 ***Biggest Aging Category being the sheet name.

1618798125398.png
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
What happens when you put the below where you want your formula,
highlight "Baseballs" (including the quotes)
Then click on where the value is that contains Baseballs
Hit enter

Excel Formula:
=GETPIVOTDATA("[Measures].[Sum of Inventory Value]",'Biggest Aging Category'!$B$4,
"[Current Inventory Report].[Org #]",
"[Current Inventory Report].[Org #].&[" &[@[Org '#]]& "]",
"[Current Inventory Report].[Primary Category]",
"[Current Inventory Report].[Primary Category].&[" & "Baseballs" & "]")
 
Upvote 0
=GETPIVOTDATA("[Measures].[Sum of Inventory Value]",'Biggest Aging Category'!$B$4,
"[Current Inventory Report].[Org #]",
"[Current Inventory Report].[Org #].&[" &[@[Org '#]]& "]",
"[Current Inventory Report].[Primary Category]",
"[Current Inventory Report].[Primary Category].&[" & "Baseballs" & "]")
Hi again Alex, & thank you for your help!
I changed a couple of things since then in trying to make it work. I used your formula, and changed it how you said. Below is what I got.
Also, it threw a #REF error.

=GETPIVOTDATA("[Measures].[Sum of Inventory Value]",'Biggest Aging Category'!$B$4,
"[Current Inventory Report].[Org #]",
"[Current Inventory Report].[Org #].&[" &[@[Org '#]]& "]",
"[Current Inventory Report].[Primary Category]",
"[Current Inventory Report].[Primary Category].&[" & 'Top Aging Catg'!C4 & "]")
 
Upvote 0
Why is the Org variable using a column in a table and the Category is not using a table reference ?
Show me where you are using the formula.
 
Upvote 0
I don't know. That's part of the mystery. The screenshot above (in my initial post) is the Pivot Table I am referencing. Do you also need to see where I am entering the formula?
 
Upvote 0
It looks like you should just be using a simple cell link, not GETPIVOTDATA, for this, since you aren't looking for the result for a specific category or org. Also, GETPIVOTDATA only works for value fields, not row/column/page/fields (which wouldn't really make sense).
 
Upvote 0
It looks like you should just be using a simple cell link, not GETPIVOTDATA, for this, since you aren't looking for the result for a specific category or org. Also, GETPIVOTDATA only works for value fields, not row/column/page/fields (which wouldn't really make sense).

Yes RoryA, I want it locked on that cell for that Org#. Then locked onto the cell below it for the next Org #. I wanted it to be more precise, however, in case the order of the Org #'s changes. If the order were to change, then I want that cell locked to that Org #. For this reason, I also tried to use Index/Match. But that seems to not work either.
=INDEX('Top Aging Catg'!$B$3:$D$7,MATCH(E7,'Top Aging Catg'!$B$3:$B$6,0),MATCH("Primary Category",'Top Aging Catg'!$B$3:$D$3,0))
In order to use this, I would need to put "$" before all the variables as above. But in doing so, now when the table expands and more rows are created (because of additional Org #'s (stores)), having that "$" on everything will not allow the formula to expand with it. I hope I explained that well enough.
 
Upvote 0
Assuming your table only expands vertically, you can reference entire columns:

Excel Formula:
=INDEX('Top Aging Catg'!$C:$C,MATCH(E7,'Top Aging Catg'!$B:$B,0))

and

Excel Formula:
=INDEX('Top Aging Catg'!$D:$D,MATCH(E7,'Top Aging Catg'!$B:$B,0))

for the value.
 
Upvote 0
Solution
Assuming your table only expands vertically, you can reference entire columns:

Excel Formula:
=INDEX('Top Aging Catg'!$C:$C,MATCH(E7,'Top Aging Catg'!$B:$B,0))

and

Excel Formula:
=INDEX('Top Aging Catg'!$D:$D,MATCH(E7,'Top Aging Catg'!$B:$B,0))

for the value.

Rory, than you so much! Works perfectly.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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