Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello everyone,
I hope you're all doing well. I'm currently working on a project and could use some guidance regarding a DAX measure. I'm trying to calculate distinct counts for different types of customers on a monthly basis, and I'm encountering a few challenges.
Specifically, I'm aiming to determine the following metrics using DAX measures:
The database has been loaded into Power Query, and I've successfully established connections in Power Pivot.
Additionally, I'm hoping to enhance this analysis by segmenting the results based on categories and brands, if possible.
If any of you have experience with DAX measures and are willing to lend a helping hand, I would greatly appreciate it. Your expertise could make a significant difference in advancing this project.
Thank you in advance for your support. Looking forward to your insights!
Best regards, Santosh
Sample database table for reference.
date | customer id |
01 January 2022 | cust-001 |
02 January 2022 | cust-002 |
03 January 2022 | cust-003 |
01 January 2022 | cust-001 |
01 February 2022 | cust-001 |
02 February 2022 | cust-002 |
03 February 2022 | cust-004 |
02 February 2022 | cust-002 |
01 March 2022 | cust-001 |
01 March 2022 | cust-002 |
01 March 2022 | cust-005 |
01 March 2022 | cust-002 |
Thank you so very much for providing me the dax. It works fine on date level when it is being analysed on month level in pivot table the result reflects as zero. Kindly have a look once more. Thanks! once again.
Try adding REMOVEFILTERS('Date') into the CALCULATETABLE calls.
You could create measures like
Lost Customers =
VAR CurrentCustomers =
DISTINCT ( 'Table'[customer id] )
VAR PrevCustomers =
CALCULATETABLE (
DISTINCT ( 'Table'[customer id] ),
DATEADD ( 'Date'[Date], -1, MONTH )
)
VAR Result =
COUNTROWS ( EXCEPT ( PrevCustomers, CurrentCustomers ) )
RETURN
Result
New Customers =
VAR CurrentCustomers =
DISTINCT ( 'Table'[customer id] )
VAR PrevCustomers =
CALCULATETABLE (
DISTINCT ( 'Table'[customer id] ),
DATEADD ( 'Date'[Date], -1, MONTH )
)
VAR Result =
COUNTROWS ( EXCEPT ( CurrentCustomers, PrevCustomers ) )
RETURN
Result
Repeat Customers =
VAR CurrentCustomers =
DISTINCT ( 'Table'[customer id] )
VAR PrevCustomers =
CALCULATETABLE (
DISTINCT ( 'Table'[customer id] ),
DATEADD ( 'Date'[Date], -1, MONTH )
)
VAR Result =
COUNTROWS ( INTERSECT ( CurrentCustomers, PrevCustomers ) )
RETURN
Result
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |