Fix GETPIVOTDATA #REF Error with Dynamic Measures in Power Pivot
Question details
The user needs to dynamically reference measure names using cell references in a Power Pivot report without triggering a #REF error.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Building a flexible financial or general-ledger report that pulls various measures dynamically based on cell references.
- Observed behavior
- The GETPIVOTDATA function returns a #REF error when its measure argument is dynamically constructed from a cell reference within a Power Pivot report.
Ensure your Power Pivot data model is fully loaded and that the exact measure names you plan to reference dynamically actually exist in the background Data Model.
Replace GETPIVOTDATA with the CUBEVALUE Function
CUBE functions are designed specifically for Data Models and natively support dynamic string concatenation and cell references for measure names, bypassing the limitations of GETPIVOTDATA.
While GETPIVOTDATA is excellent for standard Pivot Tables, it is rigid and often fails when trying to concatenate dynamic strings for measure names inside a Power Pivot Data Model. CUBEVALUE interacts directly with the Data Model rather than the visible Pivot Table, allowing complete flexibility.
Locate or create the cell containing the dynamic measure name you want to reference (e.g., cell A1 contains the text 'Total Revenue').
Click on the cell where you want the calculated value to be displayed.
Type the formula to reference the Data Model and dynamically concatenate your cell reference. For example: =CUBEVALUE("ThisWorkbookDataModel", "[Measures].[" & A1 & "]")
If you need to filter by a specific general-ledger code dynamically, add another argument linking to that cell, such as: =CUBEVALUE("ThisWorkbookDataModel", "[Measures].[" & A1 & "]", "[GL_Codes].[Code].[" & B1 & "]")

Handle Pivot Tables and Spreadsheets Seamlessly with WPS Office
While highly advanced Power Pivot Data Models and CUBE functions are specific to Microsoft Excel environments, WPS Office Spreadsheet provides a highly compatible, robust environment for standard Pivot Tables, conventional GETPIVOTDATA operations, and everyday data analysis at no cost.
- 1. Download and Install WPS Office: Visit the official WPS website, download the free installer, and complete the installation process.
- 2. Open WPS Spreadsheet: Launch the WPS Office suite and click on 'Spreadsheet' to start a new workspace.
- 3. Import Your Data: Drag and drop your existing .xlsx files into the application to continue building your standard Pivot Tables and reports.

Frequently Asked Questions
Why does GETPIVOTDATA return a #REF error for dynamic measures?
GETPIVOTDATA is structured to read directly from the visible layout of a Pivot Table. If the dynamically constructed text string isn't an exact match to a currently displayed field, or if it queries a Data Model measure in a way the layout doesn't support, it breaks and returns a #REF error.
Can I use the INDIRECT function with GETPIVOTDATA to fix the dynamic reference?
While the INDIRECT function can help build standard cell references dynamically in regular formulas, it often fails when used within the specific measure argument of a GETPIVOTDATA function connected to a Power Pivot Data Model. CUBE functions are the reliable alternative.
How do I find the correct Data Model connection name for CUBEVALUE?
In most modern spreadsheet environments that support this feature, the default local Data Model connection name used inside CUBE functions is simply "ThisWorkbookDataModel".




