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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NeimadB
Helper II
Helper II

Power BI Cumulative sum by date and by category issue

Hi there,

 

I'm facing a problem with a DAX formula that  compute a cumulative SUM for my sales of cycles.

 

I got a simple dataset SalesByCycle, with the following columns :

  • Date
  • Cycle
  • Sales

 

Date is Date column

Cycle is a category of our products

Sales is the amount sold

 

I got a Date slicer, and a Cycle Slicer that let me chose 1 or several Cycles.

 

The problem is : the categorization of the cumulative SUM doesn't work when I select more than one cycle.

 

Here is the result when I select only one cycle (cycle 1 there) : everything is fine

 

 

exemple2.PNG

 

 

Abd the result when I select all cycles (or 2 or 3) : the provessive SUM doesn't work (each Cycle that have data on this day have the same value : the grand total of the cumulation at this date)

 

exemple1.PNG

 

 

 

Here is the DAX code of my cumulative SUM :

 

 

ActualSalesByCycle =
var DateValue = MAX(SalesByCycle[Date])
var CyclesValues = ALLSELECTED(SalesByCycle[Cycle])
RETURN
CALCULATE( SUM(SalesByCycle[Sales]), FILTER(ALL(SalesByCycle), SalesByCycle[Date] <= DateValue && SalesByCycle[Cycle] IN CyclesValues ) )

 

Thank you

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @NeimadB ,

 

Here is my sample:

vjianbolimsft_1-1684482447691.png

 

Please try:

ActualSalesByCycle = 
var DateValue = MAX(SalesByCycle[Date])
RETURN
CALCULATE( SUM(SalesByCycle[Sales]), FILTER(ALL(SalesByCycle), SalesByCycle[Date] <= DateValue && SalesByCycle[Cycle] =SELECTEDVALUE(SalesByCycle[Cycle]) ) )

Final output:

vjianbolimsft_0-1684482427686.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @NeimadB ,

 

Here is my sample:

vjianbolimsft_1-1684482447691.png

 

Please try:

ActualSalesByCycle = 
var DateValue = MAX(SalesByCycle[Date])
RETURN
CALCULATE( SUM(SalesByCycle[Sales]), FILTER(ALL(SalesByCycle), SalesByCycle[Date] <= DateValue && SalesByCycle[Cycle] =SELECTEDVALUE(SalesByCycle[Cycle]) ) )

Final output:

vjianbolimsft_0-1684482427686.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.