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

How to Calculate cumulative distinct count of customers ?

Hello, 
I have dataframe that looks like this:

FiscalWeekCustomerIDRevenue
Week1110
Week1215
Week1134
Week1213
Week1315
Week1434
Week1552
Week2651
Week2761
Week2837
Week2110
Week2215
Week2334
Week2913
Week3715
Week3234
Week3152
Week31051
Week31161
Week31237
Week31310
Week41415
Week41534
Week41613
Week41215
Week4134
Week4852
Week41751
Week51861
Week51937
Week52010
Week5115
Week5234
Week5113
Week52115
Week62234
Week62352
Week6651
Week6461
Week62437
Week62554
Week62685


What I am trying to get is cumulative numbers for Revenue and unique customers.
Now for the revenue it is easy however unique customers is much more complecated.
As you can customers who purchase in first week can come back and purchase again in any of the following weeks. 
So the unique number of customers for each week should grow but i cant simply do the sum of unique. 
So the cumulative count of unique customers for every week should be something like 

count distinct values of customers since first week until now. 
That being said, for week let say, 6 it would be count distinct customerID where between Week1 and Week6. 


So my output should be in new table that has columns like this:

FiscalWeekUniqueCustomerCountTotalNetRevenue
Week1 173
Week2 221
Week3 260
Week4 214
Week5 185
Week6 

374

 

 

How do i do this with Dax?


How would i do this?

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture2.png

 

New Table =
SUMMARIZECOLUMNS (
Data[FiscalWeek],
"@TotalCustomersDistinctCountCumulate",
CALCULATE (
COUNTROWS ( VALUES ( Data[CustomerID] ) ),
FILTER ( ALL ( Data ), Data[FiscalWeek] <= MAX ( Data[FiscalWeek] ) )
),
"@TotalNetRevenue", SUM ( Data[Revenue] )
)

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

Picture2.png

 

New Table =
SUMMARIZECOLUMNS (
Data[FiscalWeek],
"@TotalCustomersDistinctCountCumulate",
CALCULATE (
COUNTROWS ( VALUES ( Data[CustomerID] ) ),
FILTER ( ALL ( Data ), Data[FiscalWeek] <= MAX ( Data[FiscalWeek] ) )
),
"@TotalNetRevenue", SUM ( Data[Revenue] )
)

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.
Anonymous
Not applicable

Awesome, 

thank you Kim , i think this will work well. 🙂

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors