How to Automatically Select the Latest Month in an Excel PivotTable Chart
Question details
The user wants to configure an Excel PivotTable and its associated waterfall chart to automatically update and select the most recent month's data after a refresh, particularly when using calculated fields.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating a dynamic waterfall chart based on PivotTable data that requires pulling the latest month automatically after a data refresh.
- Observed behavior
- Currently, the month in the chart table is static (e.g., fixed to June 2021) and does not automatically update to the newest month when new data is added and the PivotTable is refreshed.
Ensure your PivotTable source data is formatted as an Excel Table so that new rows are automatically included during a refresh, and verify that your month column contains valid numerical dates rather than text.
Use MAX and GETPIVOTDATA Formulas to Build a Dynamic Chart Table
Extract the most recent month from your source table using the MAX function and feed it into GETPIVOTDATA to dynamically populate your chart.
Standard PivotCharts may struggle to automatically filter for the 'latest month' when utilizing calculated fields like Gross Profit or Net Profit, as these fields do not exist as standard categories in the source data. The most robust workaround is to build a separate chart data table driven by formulas.
Create a helper cell outside your PivotTable. Enter the formula =MAX(Table1[Month]) (replace 'Table1' and 'Month' with your actual table and column names) to automatically calculate the most recent date.
In the separate table that drives your waterfall chart, reference the helper cell containing the latest month. This ensures your column header or month reference updates dynamically.
In the data cells of your chart table, use the GETPIVOTDATA function referencing the dynamic month cell. For example: =GETPIVOTDATA("Amount", $M$1, "Month", P$9, "Category", M11) where P$9 is your dynamic month cell and M11 is your category.
When new data is added to your source table, navigate to the 'PivotTable Analyze' tab and click 'Refresh'. The helper cell will grab the new maximum month, and the GETPIVOTDATA formulas will instantly pull the updated data into your chart.

Create Dynamic PivotTables and Charts in WPS Spreadsheet
WPS Spreadsheet offers powerful PivotTable capabilities, complete support for advanced extraction formulas like GETPIVOTDATA, and dynamic charting tools to handle complex financial data efficiently.
- 1. Insert a PivotTable: Open your dataset in WPS Spreadsheet, go to the 'Insert' tab, and click 'PivotTable' to summarize your source data.
- 2. Set up your dynamic formulas: Use the =MAX() function in a helper cell to find the latest month, then build your chart data range utilizing the =GETPIVOTDATA() function linked to your PivotTable.
- 3. Insert the Waterfall Chart: Highlight your newly created dynamic data range, navigate to 'Insert' > 'Chart', and select the Waterfall Chart type.

Frequently Asked Questions
Why does my GETPIVOTDATA formula return a #REF! error?
A #REF! error typically occurs if the specific data point you are trying to extract is hidden or filtered out in the PivotTable, or if the field names used in the formula do not exactly match the field headers in your PivotTable.
Can I use the MAX function if my month column is formatted as text?
No, the MAX function requires numerical values or valid date serial numbers to work. If your months are formatted as text strings (e.g., 'Jan', 'Feb'), you will need to add a helper column to your source data that converts those text strings into date values before applying the MAX function.
Why doesn't my waterfall chart update immediately when I paste new data?
PivotTables and GETPIVOTDATA formulas do not update in real-time when source data changes. You must manually instruct the software to update by going to the Data tab and clicking 'Refresh All' so the PivotTable recognizes the new rows.
Is there a way to auto-refresh the PivotTable without manually clicking refresh?
You can configure the PivotTable to refresh automatically when the file is opened by right-clicking the PivotTable, selecting 'PivotTable Options', navigating to the 'Data' tab, and checking 'Refresh data when opening the file'.




