return maximum value from a pivot table

StillUnderstanding

Board Regular
Joined
Jan 30, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

I wonder if anyone can help me please? I am using the following code in a cell to return the maximum value in a pivot table =INDEX(A6:A15,MATCH(MAX(B6:B15),B6:B15,0))

The issue that I have is that when the pivot table changes size its only returning the value within the code.

I think you can do this with getpivotdata but I am not sure how?

Can anyone help please?

The table is called PivotTable1

1628237400331.png
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You might try
Excel Formula:
index(a:a, match(large(b:b, 2), b:b,0))
 
Upvote 0
Hi,

If you want to this with GETPIVOTDATA you need to add a field to the pivot however without knowing how your data table is setup that's impossible without assuming to much.
And just as a note: your formula as well as the proposal from @GraH does not come back with the max value but with the month containing the max value.
 
Upvote 0
Or use a DAX measure so the pivot only returns this value. That is when loading the data in the datamodel would be an option.
 
Upvote 0
Thanks @GraH and @jorismoerings for the help on this.

@GraH you formula works well to bring back the highest month!

I am also trying to bring back the highest number so I have managed to use this formula =GETPIVOTDATA("Session",'Onboarding Pivots'!$B$5) the problem is that it brings back the total, so 470 and not 108 as I would have expected.

Do you know how I would change the formula to bring back the largest number and exclude the grand total?

Thanks again for your help so far.
 
Upvote 0
Getpivotdata only returns a value from given coordinates. In this case it returns the grand total because you do not specify the month.
I don't know how to twist it to return the max value.
You may consider not to show grand total on the pivot and use max on the (dynamic) range.
Also you already have a working formula that returns that value.
Edit:
Another twist is to sort the pivot values in descending order. The max value is then always the first.
 
Upvote 0
Hi,

GETPIVOTDATA only returns data that's available in the pivot. So without having a MAX value in the pivottable or by creating the Calculating field that does the MAX for you, getpivotdata will not work.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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