Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
Formula Syntax
Advantages of GetPivotData
Disadvantages of GetPivotData
Key Takeaways
Last Updated: Mar 27, 2024


Master Python: Predicting weather forecasts
Ashwin Goyal
Product Manager @


Microsoft Excel is powerful data visualisation and analysis software, which uses spreadsheets to store, organise, and track data sets with formulas and functions. Excel is used by marketers, accountants, data analysts, and other professionals. It's part of the Microsoft Office suite of products.


The GETPIVOTDATA function belongs to the Excel Lookup and Reference functions category. 

In an Excel Pivot Table, the function assists in extracting data from selected fields. 

The pivot table is frequently used in financial analysis to allow for a more in-depth study of data. A pivot table's data can be extracted, grouped, or added using this function.

Formula Syntax

=GETPIVOTDATA(data_field, pivot_table, [field1, item1, field2, item2], …)


The following arguments are passed to the GETPIVOTDATA function:

  • Data field (mandatory parameter) - This is the worksheet data from which non-readable characters will be removed.
  • In a pivot table, this is a reference to a cell, a range of cells, or a designated range of cells. This is a reference to a cell, range of cells, or designated range of cells in a pivot table (necessary argument). The reference specifies the pivot table.
  • This is a field/item pair: Field1, Item1, Field2, Item2 (optional parameter). To describe the data that we want to obtain, we can use up to 126 pairs of field names and item names.


All field names and names for objects other than dates and numbers must be included in quotation marks. It's important to remember the following:

  • Dates are input using the DATE function as date serial numbers, which ensures that they are in the correct date format.
  • Numbers can be directly inserted.
  • Time should be entered as a decimal value or using the TIME function.
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job


1. To reference the amount of beans sent to France, select cell B14 below and type =D7 (without clicking cell D7 in the pivot table).

2. To see only the amounts of veggies exported to each country, use the filter.


Note that cell B14 now refers to the quantity of carrots transported to France rather than the quantity of beans. GETPIVOTDATA is here to help!

3. Discard the filter. In the pivot table, select cell B14 once more, type an equal sign (=), and click cell D7.

GetPivotData Function in Excel


The GETPIVOTDATA function described above is automatically inserted by Excel.

4. Use the filter once more to only see the number of vegetables exported to each country.

Dynamic Reference

Note that the GETPIVOTDATA function delivers the right number of beans exported to France.

5. Only visible data can be returned by the GETPIVOTDATA function. Use the filter to just see the amount of fruit exported to each country, for example.

#REF! Error

Because the value 680 (beans to France) is not visible, the GETPIVOTDATA method produces a #REF! error.

6. The GETPIVOTDATA dynamic function returns the amount of data exported to Canada.

Dynamic GetPivotData Function

This GETPIVOTDATA function accepts six arguments: a data field, a reference to any cell within the pivot table, and two field/item pairs. To swiftly choose the first and second items, create a drop-down list in cells B14 and B15 (see downloadable Excel file).

7. The GETPIVOTDATA method returns the total amount exported to the United States with four arguments (data field, a reference to any column within the pivot table, and one field/item pair).

8. If the total amount exported to the United States changes (for example, due to the application of a filter), the value returned by the GETPIVOTDATA method changes as well.

This functionality can be turned off if you don't want Excel to automatically insert a GETPIVOTDATA function.

9. Select any cell within the pivot table by clicking it.

10. On the Analyze tab, in the PivotTable group, deselect Generate GetPivotData using the drop-down arrow next to Options.

Uncheck Generate GetPivotData

Advantages of GetPivotData

The GetPivotData function is a powerful tool for extracting specific data from a pivot table. Here are some of its benefits.

  • Excel creates a calculation depending on the pivot table cell that was clicked.
  • Even if the arrangement of the pivot table changes, the formula shows the right result - it has pivot field and pivot item names.
  • The formula can be changed to make it more adaptable.

Disadvantages of GetPivotData

The GetPivotData function can occasionally cause issues. Here are some of its drawbacks.

  • When compared to a simple cell reference, a formula is verbose and unclear.
  • The default formula is particular to the cell where the mouse was pressed - pivot field and pivot item names.
  • If you drag the formula to the next row, the same result appears in each row. If you try to change the GetPivotData formula, it may return problems.


1. What is Excel?

Microsoft Excel is powerful data visualisation and analysis software, which uses spreadsheets to store, organise, and track data sets with formulas and functions.

2. What are pivot tables?

A Pivot Table is a tool for summarising, sorting, reorganising, grouping, counting, totalling, or averaging data in a table. It allows us to change rows into columns and columns into rows. It lets us organise our data by any field (column) and perform complex calculations on it.

3. What should be the format of an item that contains a date?

If an item contains a date, make sure it's in date format or a serial number.

4. How can we insert functions automatically in GetPivotData?

By selecting the "Use GetPivotData functions for PivotTable references" option in MS Excel, the function can be automatically inserted.

5. When does #REF! error occurs in a pivot table?

The #REF! error occurs when:

  • The specified pivot table reference does not refer to a pivot table.
  • We use the arguments data field, [field], or [item] with invalid fields.
  • The field details aren't visible in the pivot table you've chosen.

Key Takeaways

In this article, we learnt about pivot tables in excel. We also learned about the concept of GetPivotData. We also saw an example of how to GetPivotData function in our pivot tables.

Apart from this, you can also expand your knowledge by referring to the blog- Introduction to Excel.

For more information, refer to Worksheets in Excel.

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available; take a look at the interview experiences and interview bundle for placement preparations.

Do upvote our blog to help other ninjas grow.

Happy Learning!


Previous article
Calculated Field and Calculated Item
Next article
Stock Charts
Live masterclass