Fix GETPIVOTDATA Returning Zero When Source Workbook is Closed
Question details
The GETPIVOTDATA function returns a value of zero instead of the correct data when the external source workbook it links to is closed.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Extracting data from an external PivotTable source file using the GETPIVOTDATA function across consolidated workbooks.
- Observed behavior
- Formulas show the correct values when both files are open but revert to zero as soon as the password-protected source workbook is closed.
Ensure you have the password for the protected source workbook, as you will need to open it temporarily to adjust the data connection and caching settings.
Enable PivotTable Data Caching and Refresh
Configure your PivotTable connection properties to retain the data cache so information remains available even when the source file is closed.
By default, PivotTables rely on an active connection to their source data. If the source file is password-protected, the destination workbook cannot pull the data in the background once the file is closed. Enabling data caching embeds the most recent data snapshot into the file.
Open both the consolidated destination workbook and the password-protected source workbook simultaneously in your spreadsheet application.
Right-click anywhere inside the PivotTable located in the source workbook and select 'PivotTable Options' from the context menu.
Navigate to the 'Data' tab in the options dialog box and check the box labeled 'Save source data with file'.
Manually refresh the PivotTable data while the source file is still open, then save both workbooks to preserve the cached data state.

Use IFERROR to Handle Missing Data Gracefully
Wrap your GETPIVOTDATA formula with an IFERROR function to provide an alternative value or custom warning when the source data becomes unavailable.
Create a Macro to Update Data Before Saving
Use a VBA macro to automatically refresh the data connections right before the consolidated sheet is saved, ensuring data is always captured while the source is open.
Seamlessly Manage PivotTables and External Links with WPS Spreadsheet
WPS Spreadsheet provides powerful tools to manage PivotTables, configure data caching, and handle cross-workbook references without losing your data. Enjoy high compatibility with Microsoft Excel formats and advanced data analysis features entirely for free.
- 1. Download and Install: Get WPS Office for free and open your consolidated and source workbooks in WPS Spreadsheet.
- 2. Manage PivotTable Options: Right-click your PivotTable, select 'Options', and ensure 'Save source data with file' is enabled under the Data tab.
- 3. Update Links Securely: Navigate to the Data tab and use the 'Edit Links' feature to manage and refresh external workbook connections efficiently.
- 4. Save Safely: Save your progress in universally compatible formats like .xlsx to ensure your GETPIVOTDATA formulas remain intact for all users.

Frequently Asked Questions
Why do external links break when the source file is password-protected?
Password-protected workbooks prevent external applications from accessing their data in the background. The file must be actively opened and decrypted for formulas like GETPIVOTDATA to pull the latest values, otherwise they default to zero or an error.
Can I use GETPIVOTDATA without opening the source file?
Yes, but only if the source file is not password-protected and the PivotTable data cache has been saved within the file. If these conditions are not met, the formula cannot verify the external data map.
Is there an alternative to GETPIVOTDATA for external links?
You can use standard direct cell references (e.g., ='[Source.xlsx]Sheet1'!A1) or a combination of INDEX and MATCH functions. However, if the source workbook is password-protected, even these standard references may require the source file to be open to update correctly.




