Pivot Table Issues

Count Recent Customers by Salesperson with Excel Power Pivot DAX

Steve KSteve K Dec 2, 2026 869 views

Question details

Count distinct customers who made a transaction within the last 12 months, grouped by salesperson.

Count Recent Customers by Salesperson with Excel Power Pivot DAX
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.
Before you start

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.

Solution 1Recommended

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.

1
Create a calendar table

Open Power Pivot > Manage, then select Design > Date Table > New. Ensure the calendar covers the transaction dates and the full period through today.

2
Relate the dates

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.

3
Add the measure

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())).

4
Build the PivotTable

Insert a PivotTable from the Data Model. Drag Salesperson to Rows and Number of Recent Customers to Values.

Create a Power Pivot measure for recent distinct customers
Date range and totals: The measure includes both the date 12 months ago and today. Each row counts distinct customers in that salesperson's filter context; the grand total counts distinct customers across the total context, so it may not equal the sum of the rows.
Free Microsoft Office alternative

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.

Filter transaction dates and review customer data by salesperson.Open and edit Microsoft Excel XLS and XLSX files.Work in a familiar, easy-to-use spreadsheet interface.Use a free, lightweight Office alternative.
microsoft office alternative - wps office

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.