Sub topic 14
Pulling Pivot Results into Formulas with GETPIVOTDATA
Assume you know how to create a pivot table, use cell references, and write basic functions such as SUMIFS. This chapter explains how to reference a pivot result without depending on a fixed output cell.
Why use GETPIVOTDATA?
A pivot table can move its totals when you add fields, filters, or groups. A formula such as =Pivot!B5 may then point to the wrong result. GETPIVOTDATA identifies the pivot table by an anchor cell and identifies the requested result by field names and items.
The function returns an aggregated value from a pivot table. Its general pattern is:
=GETPIVOTDATA(value_name, pivot_table, field_name, item, ...)value_nameis the name of the value being summarized, such as"Revenue".pivot_tableis a cell inside the pivot table, such asPivot!A1.- Each
field_name, itempair selects a pivot-table item, such as"Region", "West".
Requesting a specific pivot result
Suppose a sheet named Pivot contains a pivot table based on sales data. The pivot table summarizes a value field named Revenue by Region.
=GETPIVOTDATA("Revenue", Pivot!A1, "Region", "West")This asks for the Revenue value where Region is West. The reference Pivot!A1 does not mean “return the value in A1.” It tells Sheets which pivot table to search. Use any cell inside that pivot table as the anchor.
The field and item names must match the pivot table. If the pivot uses Sales region instead of Region, use that exact field name. If the item is spelled Western, "West" will not match it.
You can provide more than one condition:
=GETPIVOTDATA("Revenue", Pivot!A1, "Region", "West", "Quarter", "Q1")This returns the Revenue result for the intersection of West and Q1, if those fields are present in the pivot table.
How the reference behaves
GETPIVOTDATA is useful for dashboard cells, report headers, and variance calculations. If the pivot table is rearranged but still contains the requested fields and item, the formula can continue to return the intended result.
Cross-checking the result
A formula should be checked against the source data when the result matters. If Sales!B:B contains regions and Sales!E:E contains revenue, calculate the same total directly:
=SUMIFS(Sales!E:E, Sales!B:B, "West")The two results should agree when the pivot includes all source rows and applies no additional filters. A difference can indicate a filtered pivot, an incomplete source range, blank or text values, or mismatched criteria.
For a formula-driven summary covering every region, use QUERY:
=QUERY(Sales!A1:E, "select B, sum(E) where B is not null group by B label sum(E) 'Total revenue'", 1)Use GETPIVOTDATA when the pivot table is the report's source of truth. Use SUMIFS or QUERY when you need a summary controlled entirely by formulas.
Exercise
What does Pivot!A1 identify in =GETPIVOTDATA("Revenue", Pivot!A1, "Region", "West")?
Show answer
It identifies the pivot table that Sheets should search. It is an anchor, not necessarily the cell containing the returned value.