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
Rose__123
Helper II
Helper II

Cumulated sum by date and by group, when simalar dates appear

Hi

 

I need to calculate the cumulative sum of inventory per item in order to make a waterfall chart to display the development of items in the warehouse. The image below shows my data. The problem arises because I have multiple posts with the same date, which becomes a problem when I try to make the waterfall chart. 

 

Rose__123_0-1630788207290.png

 

How can I get past this?

Code to calculate the cumulated sum:

Cumul =
CALCULATE( SUM(Inventory_hist[Inventory_change]),
FILTER(
ALLEXCEPT( Inventory_hist, Inventory_hist[No]),
Inventory_hist[Data_change]<=EARLIER( Inventory_hist[Data_change])
))
 

\Katrine

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Rose__123 

try this measure

Measure = 
    var _total=CALCULATE(SUM(Inventory_hist[Inventory_change]),FILTER(ALL(Inventory_hist),Inventory_hist[Data_change]<=MIN(Inventory_hist[Data_change])))
    var _minNo=CALCULATE(MIN(Inventory_hist[No]),ALLEXCEPT(Inventory_hist,Inventory_hist[Data_change]))
return 
    IF(MIN(Inventory_hist[No])=_minNo,_total)

result

vxiaotang_0-1631094029399.png

 

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

5 REPLIES 5
v-xiaotang
Community Support
Community Support

Hi @Rose__123 

try this measure

Measure = 
    var _total=CALCULATE(SUM(Inventory_hist[Inventory_change]),FILTER(ALL(Inventory_hist),Inventory_hist[Data_change]<=MIN(Inventory_hist[Data_change])))
    var _minNo=CALCULATE(MIN(Inventory_hist[No]),ALLEXCEPT(Inventory_hist,Inventory_hist[Data_change]))
return 
    IF(MIN(Inventory_hist[No])=_minNo,_total)

result

vxiaotang_0-1631094029399.png

 

 

Best Regards,

Community Support Team _Tang

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

Hi @Rose__123 

sample file attached below

 

Best Regards,

Community Support Team _Tang

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

lbendlin
Super User
Super User

Waterfall charts do not work well if you have multiple data rows per x axis value. Try setting the aggregation for "cumul"  to Average, or max.

lbendlin
Super User
Super User

what exactly is the problem?  What should be the expected outcome?

@lbendlin, the problem arises e.g. on the 28. Juli, where I have five sales of 24, 48, 48, 48, and 60 items. When I calculate the cumulated sum by date (and item), then the number for all five rows will be the sum of those five sales (plus the sum of the earlier sales=276). And when I make my waterfall chart on behalf of those data, it gets the number 276 five times instead of one time. 
I know that I could make a new table that removed the repeated lines, but I would like to avoid that. 

Does it makes sense, or should I make an example?

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.