ID EN
#Lookup and reference

GETPIVOTDATA

Excel Functions

Retrieve data from a pivot table in a formula

Syntax

EXCEL
=GETPIVOTDATA(data_field, pivot_table, [field1], ...)

Arguments

Parameter Description
data_field The name of the value field to query.
pivot_table A reference to any cell in the pivot table to query.
field1 [optional] A field/item pair.

Return Value

The data requested

Details

Use the GETPIVOTDATA function to query an existing Pivot Table and retrieve specific data based on the pivot table structure. The advantage of GETPIVOTDATA over a simple cell reference is that it collects data based on structure, not cell location. GETPIVOTDATA will continue to work correctly even when a pivot table changes, as long as the field(s) being referenced is still present. The first argument, data_field, names a value field to query. The second argument, pivot_table, is a reference to any cell in an existing pivot table. Additional arguments are supplied in field/item pairs that act like filters to limit the data retrieved based on the structure of the pivot table. For example, you might supply the field "Region" with the item "East" to limit sales data to Sales in the East Regio

Examples

Examples

The first argument in the GETPIVOTDATA function names the field from which to retrieve data. The second argument is a reference to a cell that is part

EXCEL
=GETPIVOTDATA("Sales",$B$4) // returns 138602
Examples

Fields and item pairs are supplied in pairs entered as text values. To get total sales for the Product Hazelnut:

EXCEL
=GETPIVOTDATA("Sales",$B$4,"Product","Hazelnut") // returns 62456
Examples

To get total Sales for the West region:

EXCEL
=GETPIVOTDATA("Sales",$B$4,"Region","West") // returns 41518
Examples

To get total sales for Almond in the East region, you can use either of the formulas below:

EXCEL
=GETPIVOTDATA("Sales",$B$4,"Region","East","Product","Almond")
=GETPIVOTDATA("Sales",$B$4,"Product","Almond","Region","East")
Examples

You can also use cell references to provide field and item names. In the example shown above, the formula in I8 is:

EXCEL
=GETPIVOTDATA("Sales",$B$4,"Region",I6,"Product",I7)
Dates and times

When using GETPIVOTDATA to fetch information from a pivot table based on a date or time date or time, use Excel's native format, or a function like th

EXCEL
=GETPIVOTDATA("Sales",A1,"Date",DATE(2021,4,1))