Section: Excel & Google Sheets

GETPIVOTDATA in Excel pulls one number out of a pivot table with a formula. You name the value field and the items you want, and Excel returns that cell, even when the pivot table moves. This guide covers the syntax, a worked example with real totals, why the formula returns #REF!, and how to switch off the automatic version Excel writes when you click a pivot cell.
What GETPIVOTDATA does
Microsoft describes the function as returning visible data from a PivotTable. That word visible matters. GETPIVOTDATA reads the pivot table as it is currently laid out, so a filter that hides a region also hides it from the formula.
The practical use is a dashboard cell that survives a refresh. A plain cell reference like =B7 points at a position. When the pivot table grows a row, B7 may hold something else. A GETPIVOTDATA formula points at a field and an item, so it keeps finding the same figure.

The syntax
=GETPIVOTDATA(data_field, pivot_table, [field1, item1, field2, item2], ...)
- data_field is the name of the pivot field holding the value, in quotes, such as "Sales".
- pivot_table is a reference to any cell inside the pivot table. It only tells Excel which pivot to read.
- field and item pairs are optional. Microsoft allows 1 to 126 pairs, and they can be in any order.
With no pairs, the formula returns the grand total for that field. Each pair narrows the result to one row and column combination.

A worked example
Microsoft's sample pivot table gives these results, and they are worth reading as a set:
=GETPIVOTDATA("Sales",$A$3)returns 5,534, the grand total.=GETPIVOTDATA("Sum of Sales",$A$3)also returns 5,534. The field name can be written exactly as it appears in the sheet, or as its root without "Sum of".=GETPIVOTDATA("Sales",$A$3,"Month","Mar")returns 2,876, the March total.=GETPIVOTDATA("Sales",$A$3,"Month","Mar","Product","Produce","Sales Person","Buchanan")returns 309.
Two things stand out. March alone is more than half of the 5,534 grand total, and adding two more pairs narrows 2,876 down to 309. Each extra pair is a filter, so the order of the pairs does not change the answer.
Why you get #REF!
Microsoft lists two causes. The first is that the pivot_table argument is not a range containing a pivot table. The second is that the arguments do not describe a visible field, or they include a report filter whose data is not displayed.
Their examples show both: =GETPIVOTDATA("Sales",$A$3,"Region","South") returns #REF! when South is filtered out, and =GETPIVOTDATA("Sales",$A$3,"Product","Beverages","Sales Person","Davolio") returns #REF! because there is no beverage total for that person.
So a #REF! here usually means the data exists but is not showing, not that you typed the formula wrong. Clear the filter, or check the spelling of the item. If a slicer is doing the filtering, the slicer guide shows where its state lives.

Field names, calculated fields and dates
Calculated fields and custom calculations can be read by GETPIVOTDATA, according to Microsoft's notes. The field name is the one in the pivot table, so a calculated field called Margin is written "Margin".
Dates need care. An item that contains a date must be a serial number or be built with the DATE function, so the value survives a change of locale. Microsoft's example is March 5, 1999, entered as 36224 or as DATE(1999,3,5). Times work the same way, as decimals or with the TIME function.
Turn off the automatic formula
Type = in an empty cell and click a number inside a pivot table, and Excel writes a GETPIVOTDATA formula for you. That is handy once and annoying when you wanted a simple reference.
To stop it, click any cell in the pivot table, open PivotTable Analyze, then PivotTable, then Options, and clear Generate GetPivotData. Microsoft's screenshot of that menu shows the option ticked by default.
Reference the item, do not type it
Arguments can be references instead of typed text. =GETPIVOTDATA("Sales",$A$3,"Month",$A11) reads the month from A11, so a small dropdown or a list of months drives the whole report. This is how a summary sheet of twelve formulas stays short. Pair it with date grouping in a pivot table and one formula per month is enough.

Common problems
- #REF! after a filter change. The item is not visible. Clear the filter or widen it.
- #REF! after moving the pivot. The pivot_table reference no longer sits inside a pivot table.
- Two pivots on one range. Excel reads the pivot table created most recently, so keep the reference inside the pivot you mean.
- The field name is rejected. Use the name as it appears in the pivot, or its root without "Sum of".
- Dates fail in another locale. Use DATE or the serial number, not a typed date string.
- Grand total instead of one row. The field and item pairs are missing.
Questions and answers
What is GETPIVOTDATA used for?
It returns one value from a pivot table by field and item, so the formula keeps working when the pivot table changes size.
Why does clicking a pivot cell create a formula?
Generate GetPivotData is on by default. Turn it off in PivotTable Options if you want plain references.
Does GETPIVOTDATA work with a filtered pivot table?
Only for data that is visible. A hidden region returns #REF!.
Can it read a calculated field?
Yes, Microsoft says calculated fields and custom calculations can be included.
Is it available in older Excel versions?
Microsoft lists it for Excel 2016 and later, Excel 2021, Excel 2024, Microsoft 365, the web and Mac versions.
