Function · Lookup

Excel GETPIVOTDATA function

The Excel GETPIVOTDATA function returns a PivotTable value by field name. South sales of $12,480 stay put when the pivot is rearranged. A hidden item returns #REF!.

All current Excel versions. Also in Excel for the web and Google Sheets.

Syntax =GETPIVOTDATA(data_field, pivot_table, [field1, item1], ...)

GETPIVOTDATA
=GETPIVOTDATA("Sales",$A$3,"Region","South")

Arguments

NameRequiredWhat to pass
data_fieldRequiredThe value field, in quotes. Sales and Sum of Sales both work for a field named Sales that the pivot sums.
pivot_tableRequiredAny cell inside the PivotTable. It tells Excel which pivot to read.
field1OptionalA field name, such as Region. Pair it with item1.
item1OptionalThe item in that field, such as South. Add more pairs to narrow the cell.

Examples

South from a regional sales pivot

=GETPIVOTDATA("Sales",$A$3,"Region","South")

Result $12,480

=GETPIVOTDATA("Sales",$A$3,"Region",D2)D4
Pivot
ABCD
1Region asked for
2South
3RegionSum of Sales
4North980012480
5South12480
6Grand Total22280
A picture of the sheet, not a live calculator. A3 is inside the pictured pivot. Microsoft documents that a filtered-out item returns #REF!.

GETPIVOTDATA asks a PivotTable for a value by name. Region South of the Sales field is $12,480 on this picture. North is $9,800 and the grand total is $22,280. Excel writes this function for you when you click a pivot cell while building a formula, if the option Generate GetPivotData is on.

The point is that South remains South when someone sorts the pivot or swaps rows and columns. A formula that points at B5 instead breaks as soon as the layout moves. The cost is #REF! when South is filtered out or the field is renamed. The data_field can be the source name, Sales, or the label on the pivot, Sum of Sales. Dates used as items should be real dates, not text, or the match fails when the file opens under another regional setting.