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!.
Syntax =GETPIVOTDATA(data_field, pivot_table, [field1, item1], ...)
=GETPIVOTDATA("Sales",$A$3,"Region","South")Arguments
| Name | Required | What to pass |
|---|---|---|
| data_field | Required | The value field, in quotes. Sales and Sum of Sales both work for a field named Sales that the pivot sums. |
| pivot_table | Required | Any cell inside the PivotTable. It tells Excel which pivot to read. |
| field1 | Optional | A field name, such as Region. Pair it with item1. |
| item1 | Optional | The 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
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Region asked for | |||
| 2 | South | |||
| 3 | Region | Sum of Sales | ||
| 4 | North | 9800 | 12480 | |
| 5 | South | 12480 | ||
| 6 | Grand Total | 22280 |
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.