Count Recent Customers by Salesperson with Excel Power Pivot DAX
Question details
Count distinct customers who made a transaction within the last 12 months, grouped by salesperson.

- Product
- Microsoft Excel Power Pivot
- Device & OS
- not provided
- Scenario
- Analyze transaction data by salesperson in a Power Pivot PivotTable.
- Observed behavior
- The desired PivotTable shows a distinct count of recent customers for each salesperson.
Check that Power Pivot is available in your Excel edition and that the transaction table is loaded into the Data Model. Confirm that it contains salesperson, customer name, and transaction date columns.
Create a Power Pivot measure for recent distinct customers
Use a related calendar table and a DAX measure to count customers with transactions in the rolling 12-month date range.
Open Power Pivot > Manage, then select Design > Date Table > New. Ensure the calendar covers the transaction dates and the full period through today.
In the Power Pivot window, open Diagram View and create a one-to-many relationship from Calendar[Date] to Table1[Transaction Date]. Use date-only values in the transaction date column if it contains times.
In Excel, select Power Pivot > Measures > New Measure. Name it Number of Recent Customers and enter this formula, replacing table and column names if needed: =CALCULATE(DISTINCTCOUNT(Table1[Customer Name]), DATESBETWEEN('Calendar'[Date], EDATE(TODAY(), -12), TODAY())).
Insert a PivotTable from the Data Model. Drag Salesperson to Rows and Number of Recent Customers to Values.

Explore customer transaction data in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for an easier transition. It can help you filter and analyze transaction data, but it does not fix or replace the Excel Power Pivot DAX measure described above.

Frequently Asked Questions
Why do I need a calendar table for this measure?
The DATESBETWEEN function filters the calendar's date column, and the relationship passes that filter to the transaction table. Create the calendar in Power Pivot > Manage > Design > Date Table > New.
Does a customer with several transactions get counted more than once?
No. DISTINCTCOUNT counts each customer name once within the current salesperson and date-filter context.
Why is the grand total different from the sum of the salesperson rows?
The grand total counts distinct customers across the total filter context. A customer who bought from multiple salespeople can appear in several rows but is counted once in the grand total.
What happens if a customer name is blank?
DISTINCTCOUNT can count a blank customer name as one distinct value. If blank names should not count, filter them out or adjust the measure to exclude them.




