How to Make a PivotTable Grand Total Sum Distinct Counts by Row
Question details
The user needs the Grand Total of a PivotTable to display the sum of distinct counts from individual rows, rather than calculating a single distinct count for the entire dataset.

- Product
- Spreadsheets
- Device & OS
- not provided
- Scenario
- Creating a PivotTable where the required outcome is an aggregation of row-level distinct counts at the Grand Total level.
- Observed behavior
- A standard PivotTable calculates the grand total as a distinct count across the entire dataset, which results in a number lower than the actual sum of the distinct counts shown for the individual rows.
Before applying advanced data models or formulas, clearly identify which column represents the values to be counted and ensure your source dataset contains no blank headers or merged cells.
Use Power Pivot and a Data Model Measure
Create a DAX measure within the Data Model to control the distinct-count calculation and force the Grand Total to sum the row-level totals.
By default, standard PivotTables evaluate the Grand Total context over the entire dataset. By loading your data into the Data Model and using Power Pivot, you can write a DAX formula that iterates through each row category before summing up the distinct counts.
Select your source data table, go to the Insert tab, click 'PivotTable', and check the box that says 'Add this data to the Data Model' before clicking OK.
Right-click the table name in the PivotTable Fields pane and select 'Add Measure' (or navigate to the Power Pivot tab and select 'New Measure').
Enter a formula using an iterator function. A common structure is: =SUMX(VALUES(Table[RowField]), CALCULATE(DISTINCTCOUNT(Table[ValueField]))). Replace the table and field names with your actual data.
Drag this newly created measure into the Values area of your PivotTable. The Grand Total will now correctly display the sum of the distinct counts from the rows above.

Use a Helper Column in the Source Data
If you are not familiar with Power Pivot, adding a formula-based helper column to your raw data can achieve the same row-based sum in a standard PivotTable.
Easily Handle Complex PivotTable Calculations with WPS Office
WPS Spreadsheet offers powerful data analysis capabilities, full support for complex formulas, and intuitive PivotTable features, allowing you to easily implement helper column solutions for distinct counts.
- 1. Open your dataset: Launch WPS Spreadsheet and open the workbook containing the data you want to analyze.
- 2. Add a helper column: Create a new column and use the COUNTIFS formula approach to assign fractional values to your distinct items.
- 3. Insert PivotTable: Highlight your updated data range, navigate to the Insert tab, and select PivotTable.
- 4. Configure Values: Drag your new helper column to the Values area and set it to 'Sum' to instantly generate accurate row-based distinct count totals.

Frequently Asked Questions
Why does my PivotTable Grand Total show a smaller number than the sum of the rows?
By default, a PivotTable calculates the Grand Total by applying the aggregate function (like Distinct Count) to the entire dataset at once. If an item appears in multiple rows, it is only counted once overall, making the Grand Total lower than the sum of the individual row totals.
Can I fix the Grand Total distinct count without using Power Pivot?
Yes. You can add a helper column directly to your source data using a formula like =1/COUNTIFS(...). This formula assigns a fractional value to duplicate entries. When you sum this helper column in a regular PivotTable, the distinct count will total correctly at both the row and Grand Total levels.
What DAX functions do I need to sum distinct counts in Power Pivot?
To force the Data Model to sum the distinct counts of rows, you generally need to combine an iterator function like SUMX with VALUES and DISTINCTCOUNT. A common pattern is SUMX(VALUES(Table[RowCategory]), CALCULATE(DISTINCTCOUNT(Table[ItemToCount]))).




