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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
hjrodrig
Frequent Visitor

Running total by date with positive and negative values

Hey Guys,

 

I'm trying to do a simple running total going by date of a value that includes positive and negative values. I'm using the following calculation:

 

Cashflow Running Total =

CALCULATE(Cashflow

FILTER( ALLSELECTED('Mock’ [Date]),

'Mock’[Date] <= max('Mock’[Date])))

 

The issue here is that it does the running totals for positive and negative values separately (See ' Wrong Running Total' column). What I need is the right running total below but can't figure it out. I'm sure its super simple. Any help would be appreciated! Thanks guys.

 

DateCashflowWrong Running TotalRight Running Total
1/2/2019111
1/3/2019011
1/4/2019566
1/14/2019-5-51
3/12/2019283
3/13/20192105
3/14/2019-2-73
6/23/20191114
6/24/20194158
6/25/201952013

 

2 ACCEPTED SOLUTIONS
Nathaniel_C
Community Champion
Community Champion

Hi @hjrodrig ,
Try this:

Calc run total = 
var _endate =LASTDATE(mock[Date])
return CALCULATE([Cashflow Amount],ALLEXCEPT(mock,mock[Date]),mock[Date]<=_endate)

rt.PNG

 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Sorry pic is not going through but I get an error message saying " A single value for column 'Date' in table x cannot be determined. This happens when an aggregation min, max, sum etc is not used...."

View solution in original post

7 REPLIES 7
Nathaniel_C
Community Champion
Community Champion

Hi @hjrodrig ,
Try this:

Calc run total = 
var _endate =LASTDATE(mock[Date])
return CALCULATE([Cashflow Amount],ALLEXCEPT(mock,mock[Date]),mock[Date]<=_endate)

rt.PNG

 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




mwegener
Most Valuable Professional
Most Valuable Professional

Hi @hjrodrig ,

 

what does your Cashflow measure?

Do you use a date table?

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Cashflow is just a net transactional value for that day on the date field. That all the data I have, so probably don't use a date table. Really appreciate it!

mwegener
Most Valuable Professional
Most Valuable Professional

I would always recommend a date table.

And I hope your measure makes a simple sum.

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Hi @hjrodrig , @mwegener 

Cashflow Amount = SUM(mock[Cashflow])


For the previous measure.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you Nathaniel, this is definitely it, but I ran into the following issue. A particular date might have multiple transactions in one day in the real dataset, so I'm thinking this is where the error is coming from.

 

 

Thanks a lot man.

 

 

 

Sorry pic is not going through but I get an error message saying " A single value for column 'Date' in table x cannot be determined. This happens when an aggregation min, max, sum etc is not used...."

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.