Forum Discussion

Mederic's avatar
Mederic
Post Patron
2 years ago
Solved

Running total

Hello, I have a Power query code that works in the 1st case but not in the 2nd (see screenshot below) How can I please modify this code so that it works in both cases ?     =List.Sum(Table.Sele...
  • spinfuzer's avatar
    2 years ago

    The formula only works when the [Column] is in Ascending Order (e.g. next row is always greater than the next).  If you want to use that formula, Add an [Index] column before adding the running total. 

     

    =List.Sum(Table.SelectRows(#"Changed Type", (x)=> x[Index]<=[Index])[Qty])

     

    The formula is not efficient, but it will work if you are a beginner and you have a small data set.