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

Calculate rolling sum to reset to negative when rolling sum is 0

This is my data. I need the adjustedcumsum in DAX.  I get the cumsum from sum. The cumum has to reset when value is negative and recalculate.

 

dateSUMCumsumAdjustedSum
2-1-2020   -2-20
7-1-2020202
8-1-2020-1-11
10-1-2020435
13-1-2020-124
14-1-2020135
15-1-2020146
16-1-2020-135
17-1-2020146
19-1-2020379
20-1-2020-346
21-1-2020046
22-1-2020157
23-1-2020-146
24-1-2020268
25-1-2020179
27-1-20202911
28-1-202011012
29-1-202011113
31-1-202021315
4-2-2020-21113
5-2-202021315
6-2-202021517

 

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

Hi @niveekiwi ,

 

Is "sum" a column or measure?

 

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

Sum is a measure.

Fowmy
Super User
Super User

Your result column AdjustedCumSum isn't showing the correct results, could you explain a bit more?

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

So when my cumsum is negative (since sum is -2) in the first row is -2, the cumsum becomes 0. Then the rolling sum is recalculated again. So sum in the second row is 2, so then adjusted cumsum is 2. That is my new running sum. based on which the cumsum is calculated again. Hope that makes sense.

Why doesn't it reset with the -1 value?  Please explain the needed logic to not reset there.

Regards,

Pat

 





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


When the cumsum is -1 on 08/01/2020; the new adjusted cumsum is 2 on 07/01/2020; and sum on 08/01/2020 is -1. So 2-1 is still 1 when the asjusted cumsum is considered.

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.