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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PeterBI
Helper I
Helper I

looking for a simple running Total solution

Hello, 

i'm looking for a simple solution to get the running total like this Excel Solution. Thanks in advance.

 

IndexSaldoRunning Total
100
2-87,5-87,5
3-225-312,5
4-237,5-550
5350-200
6-75-275
70-275
812,5-262,5
950-212,5
1012,5-200
11-12,5-212,5
1250-162,5
1337,5-125
14-150-275
15450175
16-15025
13 REPLIES 13
Greg_Deckler
Community Champion
Community Champion

http://www.daxpatterns.com/cumulative-total/



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks, i know your Site but every solution Group Data especially with the Date. I'm very Happy if there is a simple Way only maybe with the Index Row.

 

And please don't forget, I'm new to BI, so the first Steps are a little bit bumpy 😉

 

Regards, Peter

ImkeF
Community Champion
Community Champion

Hallo Peter,

you can do it in the query-editor instead, using M. Assuming your imported table sits in a step called "Source", you add a column where you fill in this formula:

 

(x)=> List.Sum(Table.SelectRows(Source, each [Index]<=x[Index])[Saldo])

 

You will then need to edit your code in the advanced editor and delete the "each" in the statement that has been generated:

 

PBI_CumulativeTotal.png

 

The full code of your query would look like this then:

let
    Source = Excel.CurrentWorkbook(){[Name="Tabelle1"]}[Content],
    #"Added Custom" = Table.AddColumn(Source, "Custom", (x)=> List.Sum(Table.SelectRows(Source, each [Index]<=x[Index])[Saldo]))
in
    #"Added Custom"

 

... or (x)=> List.Sum(Table.SelectRows(Source, (y) => y[Index]<=x[Index])[Saldo])

 

according to the discussion that is currently going on here re rolling averages (containing some links on M-syntax)

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Sean
Community Champion
Community Champion

@PeterBI Try this! Just change the Table name

 

Running Total = CALCULATE(SUM(Table[Saldo]), FILTER (ALL(Table[Index]), Table[Index] <= MAX (Table[Index]) ) )

 

NOTE: Your table will HAVE TO BE SORTED by INDEX!

 

EDIT: => Use @ImkeF's answer below!

 

Hello Sean,

 

Thanks for your Idea.

This is the Formula with changed Names.

RT = CALCULATE (SUM(Trades[TradingErgebnisNetto]); FILTER (ALL(Trades[Index]); Trades[Index] <= MAX (Trades[Index]) ) )

 

There is no syntax error but the Row RT contain the same numbers as Saldo or new TradingErgebnisNetto. It ist the same error that i gete with my earlier solutions 😉 - so no running Total.

 

Data Type ist Dezimal

 

Thanks, Peter

Sean
Community Champion
Community Champion

@PeterBI

for this formula to work - the data HAS TO BE SORTED BY the INDEX Column =>1, 2, 3, etc....

So I would use @ImkeF's solution which you'll have to do in the Query Editor

 

@Sean, I tried your solution because I had essentially come up with the same thing using SUMX but neither works as far as I can tell, basically you get the total sum for all of whatever it is you are summing. I expect that it is because the ALL clause and MAX clause always returns the MAX index and thus, everything.

 

I swear I've figured something similar to this out some other way. I always thought that there should be some way to do it with EARLIER as well, but have never figured that formula out either (or I have and forgotten).



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@PeterBI @Greg_Deckler @ImkeF

 

Actually this seems to work in ANY order?

Pick any INDEX number - it gives you the Running Total up to that number - no matter how the table is sorted!

So the measure actually does exactly that - it doesn't look intuitive when you disrupt the order

But at each INDEX it gives you the Running Total up to that Index (<=MAX(Table1[Index])

RT By INDEX.png

Ah, crucial bit of information left out, create as a measure, not a column, works like that, doesn't work as a column...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi smoupre,

Thanks for this solution. As a Measure it works perfect.

Unfortunatly, i need it as a calculated column.

 

Best Regards, Peter

@PeterBI@Sean@ImkeF. Hey turns out that you can get there with EARLIER as long as you seed it the first value in your table:

 

powerbi11.png



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi smoupre,

Thanks for your solution as a column.  is there any way, to use a Index instead of the date?

Thanks, Peter

Thanks, Table is sort ba index.

I will try Imkes solution tomorrow. It would be perfect if MS has a Function built in.

 

Thanks for your Help, Good Night.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors