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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
nascarfan22
New Member

DAX help calculating Repeat Customers

Hi,

I’m working in Power BI and trying to create a DAX formula to classify purchasers as either Repeat Customers or Single Customers based on their Customer ID and the dates they made purchases.

For example:

  • If a customer makes multiple purchases on the same date (e.g., 5/1/2025), they are considered a Single Customer.

  • If they make purchases on multiple different dates (e.g., 5/1/2025 and 5/2/2025), they are classified as a Repeat Customer.

If I were doing this in Excel, I would use a Pivot Table to distinct count the number of purchase dates per Customer ID, then use a COUNTIF to determine how many customers have only one purchase date (Single Customer) versus more than one (Repeat Customer). This is what I’m trying to replicate using DAX in Power BI.

These are the DAX formulas I've tried:

Single_Customers = COUNTROWS(filter(DISTINCT('Sales'[Customer ID]),CALCULATE(COUNT('Sales'[Sales Date]))=1))
Repeat_Customers = COUNTROWS(filter(DISTINCT('Sales'[Customer ID]),CALCULATE(COUNT('Sales'[Sales Date]))>1))

 

Single_Customers = 
COUNTROWS(
    FILTER(
        VALUES('Sales'[Customer ID]),
        CALCULATE(DISTINCTCOUNT('Sales'[Sales Date])) = 1
    )
)

Repeat_Customers = 
COUNTROWS(
    FILTER(
        VALUES('Sales'[Customer ID]),
        CALCULATE(DISTINCTCOUNT('Sales'[Sales Date])) > 1
    )
)


Here is some sample data. If I did this in excel with a pivot table and distinct count it, I'd have 5 Single Customers and 1 Repeat Customer. 

Customer IDSales Date
38082/11/2025
18335/16/2025
38082/11/2025
28792/11/2025
17275/16/2025
17274/18/2025
20362/11/2025
11284/18/2025



1 ACCEPTED SOLUTION

hello @nascarfan22 

 

i am using your sample data above, please try if this match to your need.

Irwan_0-1748565583094.png

 

1. create a calculated column to check single or repeat.

Check =
var _Count =
COUNTX(
    FILTER(
        'Table',
        'Table'[Customer ID]=EARLIER('Table'[Customer ID])&&
        'Table'[Sales Date]<>EARLIER('Table'[Sales Date])
    ),
    'Table'[Customer ID]
)
Return
IF(
    _Count=1,
    "Repeat",
    "Single"
)

Irwan_0-1748565453606.png

2. create two measures for single and repeat

Single =
CALCULATE(
    DISTINCTCOUNT('Table'[Customer ID]),
    'Table'[Check]="Single"
)
Repeat =
CALCULATE(
    DISTINCTCOUNT('Table'[Customer ID]),
    'Table'[Check]="Repeat"
)
 
Hope this will help.
Thank you.

View solution in original post

7 REPLIES 7
V-yubandi-msft
Community Support
Community Support

Hi @nascarfan22 ,

Could you confirm if your issue has been resolved or if you're still facing challenges. If the solution worked for you, please consider marking it as the accepted solution so it can help other community members. If you're still experiencing issues, feel free to share the details.

 

Thank You.

V-yubandi-msft
Community Support
Community Support

Hi @nascarfan22 ,
If you’ve gone through the shared responses and reference links, and they helped solve your issue, please mark the most helpful reply as the Accepted Solution. It really helps others in the community who might be facing the same kind of problem.

Thank You.

V-yubandi-msft
Community Support
Community Support

Hi @nascarfan22 ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @nascarfan22 ,

Thank you for posting your query in the Microsoft Fabric Community.

@Irwan , has provided a detailed response that aligns with your requirements. Could you please review his guidance along with the provided PBIX file.

If you need any further clarification or additional support, feel free to let us know we’re ready  to assist.

 

Best regards,
Yugandhar.

bhanu_gautam
Super User
Super User

@nascarfan22 Create a calculated column to count the distinct purchase dates for each customer:

DAX
DistinctPurchaseDates =
CALCULATE(
DISTINCTCOUNT('Sales'[Sales Date]),
ALLEXCEPT('Sales', 'Sales'[Customer ID])
)

 

Create a calculated column to classify each customer as either "Single Customer" or "Repeat Customer":

DAX
CustomerType =
IF(
'Sales'[DistinctPurchaseDates] = 1,
"Single Customer",
"Repeat Customer"
)

 

To get the count of Single Customers and Repeat Customers, you can create measures:

DAX
Single_Customers =
CALCULATE(
DISTINCTCOUNT('Sales'[Customer ID]),
'Sales'[CustomerType] = "Single Customer"
)

Repeat_Customers =
CALCULATE(
DISTINCTCOUNT('Sales'[Customer ID]),
'Sales'[CustomerType] = "Repeat Customer"
)




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

Proud to be a Super User!




LinkedIn






Hi, this solution gives me a split of customers that is 90% repeat and 10% single. When I calculate it in excel it's closer to 60% repeat and 40% single. Is there a step that could have been missed?

hello @nascarfan22 

 

i am using your sample data above, please try if this match to your need.

Irwan_0-1748565583094.png

 

1. create a calculated column to check single or repeat.

Check =
var _Count =
COUNTX(
    FILTER(
        'Table',
        'Table'[Customer ID]=EARLIER('Table'[Customer ID])&&
        'Table'[Sales Date]<>EARLIER('Table'[Sales Date])
    ),
    'Table'[Customer ID]
)
Return
IF(
    _Count=1,
    "Repeat",
    "Single"
)

Irwan_0-1748565453606.png

2. create two measures for single and repeat

Single =
CALCULATE(
    DISTINCTCOUNT('Table'[Customer ID]),
    'Table'[Check]="Single"
)
Repeat =
CALCULATE(
    DISTINCTCOUNT('Table'[Customer ID]),
    'Table'[Check]="Repeat"
)
 
Hope this will help.
Thank you.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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