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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
SammyNed
Helper I
Helper I

Cumulative Sum

Hi team,

 

I could really use some help. i have a data table similar to that below basically showing Customer ID's and Dates that they placed an Order. I want to create a graph as below that basically shows the sum of the Loyal Customers over a time period. A Loyal Customer is someone who orders more than twice.

 

So in March we should only have 1 loyal customer (customer A with 3 orders).

In April we should have 2 loyal customers (customer A with a total of 4 orders and customer C with a total of 3 orders).

 

I have tried  the following DAX but it isnt cummulative:

 

Loyal Customers = var _CustomerOrders =
SUMMARIZE( orders, orders[cst_id],  "How Many Orders",  COUNTROWS(VALUES(orders[cst_id])))
return
COUNTROWS(FILTER( _CustomerOrders, [How Many Orders]>2) )
 
Please help
 

SammyNed_0-1626180937064.png

SammyNed_1-1626181069256.png

 

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

Loyal Customers count =
VAR _currentmonthyear =
MAX ( Dates[End of Month] )
VAR _untilcurrentmonthyeartable =
FILTER ( ALL ( Sales ), Sales[Order Date] <= _currentmonthyear )
VAR _customerscounttable =
GROUPBY (
_untilcurrentmonthyeartable,
Sales[Customer ID],
"@customerscount", SUMX ( CURRENTGROUP (), 1 )
)
VAR _loyalcustomerstable =
FILTER ( _customerscounttable, [@customerscount] > 2 )
RETURN
COUNTROWS ( _loyalcustomerstable )

 

 

Link to the PBIX file 

 

 


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

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Picture1.png

 

Loyal Customers count =
VAR _currentmonthyear =
MAX ( Dates[End of Month] )
VAR _untilcurrentmonthyeartable =
FILTER ( ALL ( Sales ), Sales[Order Date] <= _currentmonthyear )
VAR _customerscounttable =
GROUPBY (
_untilcurrentmonthyeartable,
Sales[Customer ID],
"@customerscount", SUMX ( CURRENTGROUP (), 1 )
)
VAR _loyalcustomerstable =
FILTER ( _customerscounttable, [@customerscount] > 2 )
RETURN
COUNTROWS ( _loyalcustomerstable )

 

 

Link to the PBIX file 

 

 


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.

Hi @Jihwan_Kim 

 

Thank you for your help in the first problem.

 

I was hoping you could help me adjust the Loyalty value. So instead of a fixed 2 orders making a loyal customer, i want to put a slicer on the page where the user can decide what constitutes a loyal customer, and then the slicer value can be used in the measure you described above.

 

So if the user chooses 7, then a loyal customer will be anyone with more than 7 orders.

 

The slicer should range from 1 to the maximum amount of orders by 1 single customer.

I created a table to summarize the Sales tables by ID and Count of ID (which is the number or orders).

 

Is this possible?

 

Thanks in advance

Sammy_Ned

 

Hi,
In my opinion, I think you can create a slicer by using "New Parameter" UI.

Then, in the measure, instead of 2, replace it with "selectedvalue( newparameter slicer value)".

Sorry that I could not find the sample pbix file, so I only could write like the above.

Thanks.


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.

Works perfectly.

Thanks Jihwan_Kim

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.