Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculating ditinct customers using DAX?

Hi

 

I am having Sales data of more than 200000 records. Below is the dummy data

 
 

jason2000_2-1627858846154.png

 

I want to calculate the following,

 

1) How many new customers came on a monthly basis?

 

I want to check how many new customers came on board every month. If Customer A came in Jan, then customer A should not be counted for the rest of the month. I need to calculate the distinct count of customers. I need the output as below

 

jason2000_3-1627858973886.png

 

Customer A, B, C, D came in Jan, so they should not be counted as a new customer in other months. I used distinct count, but when I compare it with month, it's not showing the correct result.

 

2) How many new customers are brought by each salesperson on monthly basis?

 

I need the same principle as above for Salesperson

 

Can anyone advise how to do?

 

 

 

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

First Month Measure : =
CALCULATE ( MIN ( Data[Month Number] ), REMOVEFILTERS('Calendar'))
 
New Customers Count : =
VAR _firstmonthbycustomer =
ADDCOLUMNS (
ALLNOBLANKROW ( Customers[Customer] ),
"@firstmonthnumber", [First Month Measure :]
)
VAR _currentmonthnumber =
SELECTEDVALUE ( 'Calendar'[Month Number] )
VAR _currentmonthnew =
FILTER ( _firstmonthbycustomer, [@firstmonthnumber] = _currentmonthnumber )
RETURN
IF ( HASONEVALUE ( 'Calendar'[Month] ), COUNTROWS ( _currentmonthnew ) )
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Picture1.png

 

First Month Measure : =
CALCULATE ( MIN ( Data[Month Number] ), REMOVEFILTERS('Calendar'))
 
New Customers Count : =
VAR _firstmonthbycustomer =
ADDCOLUMNS (
ALLNOBLANKROW ( Customers[Customer] ),
"@firstmonthnumber", [First Month Measure :]
)
VAR _currentmonthnumber =
SELECTEDVALUE ( 'Calendar'[Month Number] )
VAR _currentmonthnew =
FILTER ( _firstmonthbycustomer, [@firstmonthnumber] = _currentmonthnumber )
RETURN
IF ( HASONEVALUE ( 'Calendar'[Month] ), COUNTROWS ( _currentmonthnew ) )
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
mahoneypat
Microsoft Employee
Microsoft Employee

This article shows how most peole usually approach it with the EXCEPT function.  If this is slow, there is a faster pattern you can try by subtracting the distinctcount of the previous month from the distinctcount of the current and previous month combined.

Power BI: New and Repeat Customers - Finance BI (finance-bi.com)

 

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.