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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
zbrooks
Frequent Visitor

Resetting my cumulative total when it dips below zero

Hi

 

I have a cumulative sum that has a starting total which then needs to be adding a Loadingtotal. this loading total could be positive or negative. if the cumulitive sum goes below zero it should reset and start adding the loading total as if it was starting again but at zero. I have the following as an example

zbrooks_0-1775572333986.png

Any help would be appreciated

 

1 ACCEPTED SOLUTION

Hi @zbrooks ,

This approach is built in Power Query, so the calculation is done during data load. Because of that, it won’t respond to slicers or filters applied in the report the values will remain static regardless of user interaction.

If you need the cumulative total to change dynamically based on slicers, then the same logic would need to be implemented using a DAX measure instead.

Hope this helps.

Thank you.

View solution in original post

12 REPLIES 12
v-sshirivolu
Community Support
Community Support

Hi @zbrooks ,
I was able to reproduce this from my end using the same sample data. The issue occurs due to how the cumulative total is evaluated row by row, especially when the running value goes below zero.

To handle this correctly, I created a duplicate query and implemented the running total using a buffered list with List.Accumulate,, resetting the value to 0 whenever the cumulative result becomes negative. This avoids cyclic reference errors and ensures the calculation remains stable across all rows.

You can refer to the query in the attached PBIX file , where the cumulative logic is applied and produces the expected output.


Thank You.

 

Thanks v-sshirivolu

A quick question, will this work if i have slicers on the page?
Truly appreciate the solution. Going to have learn some power query for the future.

 
 

Hi @zbrooks ,

This approach is built in Power Query, so the calculation is done during data load. Because of that, it won’t respond to slicers or filters applied in the report the values will remain static regardless of user interaction.

If you need the cumulative total to change dynamically based on slicers, then the same logic would need to be implemented using a DAX measure instead.

Hope this helps.

Thank you.

Hi @zbrooks ,

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you

 

Hi @zbrooks ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. 

 

zbrooks
Frequent Visitor

Sample PowerBi 

I cant do this in SQL as this visual has slicers that filters it dynamically


zbrooks
Frequent Visitor

I will prepare a sample Pbix file with measures that i currently use. was just hoping someone has come accross a similiar issue and could point me in the right direction.

 

FBergamaschi
Super User
Super User

Please include, in a usable format, not an image, a small set of rows for each of the tables involved in your request and show the data model in a picture, so that we can import the tables in Power BI and reproduce the data model. The subset of rows you provide, even is just a subset of the original tables, must cover your issue or question completely. Alternatively, you can share your .pbix via some cloud service and paste the link here. Do not include sensitive information and do not include anything that is unrelated to the issue or question. Please show the expected outcome based on the sample data you provided and make sure, in case you show a Power BI visual, to clarify the columns used in the grouping sections of the visual.

 

Need help uploading data? click here

 

Want faster answers? click here

DateLoadingTotalStartTotalCumulative_IncorrectCumulative_Correct
2026/04/012560476573247324
2026/04/02-1140061846184
2026/04/03-2847033373337
2026/04/04-2291010461046
2026/04/05-17230-6770
2026/04/06-17070-23840
2026/04/0717250-6591725
2026/04/08-4170-10761308
2026/04/09-4160-1492892
2026/04/10-740-1566818
2026/04/11-18230-33890
2026/04/12-13210-47100
2026/04/13-2070-49170
2026/04/1400-49170
2026/04/1500-49170
2026/04/1600-49170
2026/04/1700-49170
2026/04/1800-49170
2026/04/1950000835000
2026/04/2000835000
2026/04/21-7140-6314286
2026/04/22-7140-13453571
2026/04/23-7140-20602857
2026/04/24-7140-27742143
2026/04/25-7140-34881429
2026/04/26-7140-4203714
2026/04/27-1140-4317600
2026/04/281450701019115107
2026/04/29001019115107
2026/04/30-14530873713654

DateLoadingTotalStartTotalCumulative_IncorrectCumulative_Correct
2026/04/012560476573247324
2026/04/02-1140061846184
2026/04/03-2847033373337
2026/04/04-2291010461046
2026/04/05-17230-6770
2026/04/06-17070-23840
2026/04/0717250-6591725
2026/04/08-4170-10761308
2026/04/09-4160-1492892
2026/04/10-740-1566818
2026/04/11-18230-33890
2026/04/12-13210-47100
2026/04/13-2070-49170
2026/04/1400-49170
2026/04/1500-49170
2026/04/1600-49170
2026/04/1700-49170
2026/04/1800-49170
2026/04/1950000835000
2026/04/2000835000
2026/04/21-7140-6314286
2026/04/22-7140-13453571
2026/04/23-7140-20602857
2026/04/24-7140-27742143
2026/04/25-7140-34881429
2026/04/26-7140-4203714
2026/04/27-1140-4317600
2026/04/281450701019115107
2026/04/29001019115107
2026/04/30-14530873713654

Hi @zbrooks 

is the table you provided me a pure dataset or includes some measure results? I mean: please send me only the raw columns you have and the code of the measures you have already implemented. So I can start from there

 

Anyway it looks like a recursive calculation at first sight, so better to be done in SQLenvironments but I might be wrong.

 

Thanks

DateLoadingTotalStartTotalCumulative_IncorrectCumulative_Correct
2026/04/012560476573247324
2026/04/02-1140061846184
2026/04/03-2847033373337
2026/04/04-2291010461046
2026/04/05-17230-6770
2026/04/06-17070-23840
2026/04/0717250-6591725
2026/04/08-4170-10761308
2026/04/09-4160-1492892
2026/04/10-740-1566818
2026/04/11-18230-33890
2026/04/12-13210-47100
2026/04/13-2070-49170
2026/04/1400-49170
2026/04/1500-49170
2026/04/1600-49170
2026/04/1700-49170
2026/04/1800-49170
2026/04/1950000835000
2026/04/2000835000
2026/04/21-7140-6314286
2026/04/22-7140-13453571
2026/04/23-7140-20602857
2026/04/24-7140-27742143
2026/04/25-7140-34881429
2026/04/26-7140-4203714
2026/04/27-1140-4317600
2026/04/281450701019115107
2026/04/29001019115107
2026/04/30-14530873713654

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.