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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.


Go to My LinkedIn Page


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.


Go to My LinkedIn Page


mahoneypat
Employee
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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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