Create a Cumulative Distinct Count in Excel Power Pivot
Question details
Create a running distinct count that removes the date-column filter while preserving other filters.

- Product
- Microsoft Excel Power Pivot
- Device & OS
- not provided
- Scenario
- A PivotTable needs to show the cumulative number of distinct IDs up to each date, subject to filters on other columns.
- Observed behavior
- The desired measure counts each ID once through the current date while retaining applicable non-date-column filters.
Make sure the fact table and a separate Date table are in the Excel Data Model and have an active relationship between their date columns. Use the Date table's date column in the PivotTable, and identify the fact-table column whose distinct values you want to count.
Create a cumulative distinct count measure with DAX
Use this measure to count distinct IDs through the current date without clearing filters on other columns.
In Excel, select Power Pivot > Measures > New Measure. Choose the table where you want to store the measure.
Name the measure Cumulative Distinct Count and enter: =VAR CurrentDate = MAX('Date'[Date]) RETURN CALCULATE(DISTINCTCOUNT(Fact[ID]), FILTER(ALL('Date'[Date]), 'Date'[Date] <= CurrentDate)). Replace the table and column names with those in your Data Model, then select OK.
In the PivotTable Fields pane, add 'Date'[Date] to Rows and Cumulative Distinct Count to Values. Add other fields as filters or slicers as needed.
Apply a non-date filter in the PivotTable or a slicer and confirm that the cumulative count changes accordingly. Check several dates against the source records.

Work with spreadsheet data in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for working with spreadsheets. Its Microsoft Office format compatibility can make it easier to move everyday files between applications; it does not fix Excel Power Pivot or replace this DAX measure.

Frequently Asked Questions
Why does the measure use a separate Date table?
A related Date table supplies the date context for the PivotTable and lets the measure remove the filter on 'Date'[Date] before applying the cumulative date range. Check the active relationship in Power Pivot's Diagram View.
Will a Year or Month filter be removed?
No. ALL('Date'[Date]) removes the filter on the date column only. Filters on other columns, including Year and Month in the Date table, remain and can limit which dates are counted.
Does DISTINCTCOUNT include blank IDs?
Yes. DISTINCTCOUNT counts a blank as a distinct value. If blank IDs should be excluded, add an appropriate nonblank filter to the measure.
Why might the count not accumulate across all earlier dates?
Check that the PivotTable uses 'Date'[Date], that the Date table has an active relationship to the fact table, and that other Date table columns or fact-table date filters are not restricting the earlier dates.




