Show Monthly Expense Totals and a Period Average in an Excel PivotTable
Question details
Show monthly expense totals in a PivotTable while displaying the average monthly total for the selected period in the Grand Total column.

- Product
- Microsoft Excel Power Pivot
- Device & OS
- not provided
- Scenario
- A PivotTable report has months in columns and needs a different calculation for the Grand Total column.
- Observed behavior
- Each month should show its expense total, and the Grand Total column should show the average of the monthly totals for the selected period.
Check that your Excel version supports the Data Model and Power Pivot measures. Your source data should include date, amount, and type columns, with expense rows identified consistently.
Create a Power Pivot measure for monthly totals and their average
Use a measure that returns an expense sum for each month and averages the monthly sums across the selected period.
The measure below averages monthly totals, not individual expense transactions. It assumes the month field is a date representing the first day of each month, so months from different years remain distinct.
In the source Excel table named Data, add a Month column with =DATE(YEAR([@Date]),MONTH([@Date]),1). Format it as mmm yyyy, and adjust the table and column names if necessary.
Select the source table, choose Insert > PivotTable, and select Add this data to the Data Model. If the table is already in the Data Model, refresh it after adding the Month column.
On the Power Pivot tab, choose Measures > New Measure. Select the Data table, name the measure Monthly Expense Display, and enter this formula: =IF(HASONEVALUE(Data[Month]), CALCULATE(SUM(Data[Amount]), Data[Type]="Expense"), AVERAGEX(VALUES(Data[Month]), CALCULATE(SUM(Data[Amount]), Data[Type]="Expense"))). Adjust the names and expense label to match your data.
In PivotTable Fields, put Data[Month] in Columns and Monthly Expense Display in Values. Add any desired row fields and date filters, and turn on column grand totals from PivotTable Design > Grand Totals.
Compare a few month columns with the source expense totals, then check that the Grand Total column equals the average of those monthly totals for the selected period.

Work with expense reports in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Microsoft Excel formats, making it easy to move existing workbooks. Use PivotTables and worksheet formulas to summarize expenses; Excel Power Pivot measures may not work the same way in WPS.

Frequently Asked Questions
Why not use AVERAGE on the Amount column for the Grand Total?
AVERAGE(Data[Amount]) averages individual expense records. To average monthly totals instead, use AVERAGEX over the month field and calculate the expense sum for each month.
How do I keep January from different years separate?
Create a Month column containing the first date of each month with =DATE(YEAR([@Date]),MONTH([@Date]),1), then use that field in PivotTable Columns. Format it as mmm yyyy.
How do I show the Grand Total column?
Select the PivotTable and choose PivotTable Design > Grand Totals. Select an option that turns on grand totals for columns.
Will the average change when I filter the report?
Yes. The measure uses the current PivotTable filter context, so date filters, slicers, and other applicable filters affect the months and expenses included.
Are months with no expenses included in the average?
Not automatically. AVERAGEX ignores blank monthly results, and months absent from the source data are not available in Data[Month]. Include zero months explicitly if they must count toward the average.




