Function Problems

Excel Power Pivot: Count Customers in the Latest Month Without Filters

Chanuka GeekiyanageChanuka Geekiyanage Nov 27, 2026 869 views

Question details

Create a Power Pivot measure that counts distinct customers in the latest available month without unwanted source-table filters.

Count Latest-Month Customers Without Filters in Excel Power Pivot
Product
Microsoft Excel Power Pivot
Device & OS
not provided
Scenario
A PivotTable uses a calendar table and a customer source table, but the latest-month count should ignore filters that would otherwise change the result.
Observed behavior
The distinct customer count can change when filters on the source table affect the measure.
Before you start

Identify the calendar date column, source-table date column, and customer ID column in the Data Model. Confirm that the calendar is related to the source table and that its latest date represents the month you want to count.

Solution 1Recommended

Create a DAX measure that clears filters and selects the latest calendar month

Use this approach when the calendar table ends in the latest month to report and you want to ignore source-table and calendar filters.

The example assumes an active relationship from 'Calendar'[Date] to 'Sales'[Date], with the calendar filtering the Sales table. Replace the table and column names with those in your model.

The latest month comes from the calendar, not necessarily the latest transaction. If the calendar includes future months, restrict it to the intended reporting range or change the latest-date calculation to match your business rule.

1
Check the relationship

Open Power Pivot > Manage, then use Diagram View to confirm that 'Calendar'[Date] has an active relationship to 'Sales'[Date].

2
Add the measure

In Excel, open Power Pivot > Measures > New Measure. Select the appropriate table, name the measure Latest Month Customers, and enter this formula in the formula box: =VAR LatestDate = CALCULATE(MAX('Calendar'[Date]), ALL('Calendar'), ALL('Sales')) VAR MonthStart = DATE(YEAR(LatestDate), MONTH(LatestDate), 1) VAR MonthEnd = EOMONTH(LatestDate, 0) RETURN IF( ISBLANK(LatestDate), BLANK(), CALCULATE( DISTINCTCOUNT('Sales'[CustomerID]), ALL('Sales'), FILTER(ALL('Calendar'), 'Calendar'[Date] >= MonthStart && 'Calendar'[Date] <= MonthEnd) ) )

3
Test the result

Add Latest Month Customers to the PivotTable Values area. Compare it with a manual distinct count for the same month, then change source-table and date filters to check that the result remains as intended.

Create a DAX measure that clears filters and selects the latest calendar month
Check your model and customer IDs: Other related tables or bidirectional relationships can affect filter behavior, so test the measure with your model. DISTINCTCOUNT includes a blank customer ID as a distinct value; exclude blanks if they should not be counted.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday workbook tasks between applications. It does not fix Microsoft Power Pivot or guarantee compatibility with Power Pivot data models and DAX measures.

Open and edit common Excel workbook formats, including XLSX and XLSReview customer tables and perform everyday spreadsheet analysisUse a familiar interface for a smoother transition from Microsoft OfficeWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does my latest-month customer count change with slicers?

Slicers add filter context to the PivotTable. In the measure, use ALL or REMOVEFILTERS inside CALCULATE to clear the filters you do not want, then apply the intended month filter.

What if my calendar table contains future dates?

MAX('Calendar'[Date]) may select a future month with no sales. Adjust the calendar's reporting range or calculate the latest date according to your business rule, such as the latest transaction date.

Does DISTINCTCOUNT count blank customer IDs?

Yes. DISTINCTCOUNT treats a blank as a distinct value. If blanks are invalid customer IDs, add an appropriate nonblank filter to the measure and test the result.

Why does the measure show a different result from my manual count?

Check the active relationship in Power Pivot > Manage > Diagram View, confirm the latest calendar month, and compare the customer IDs included in that month. Also check filters from related tables and whether blank IDs are counted.