Long Time no see
Long Time no see

Reputation: 27

Power Query - Update column based on previous row

I have the following table on Power Query:

enter image description here

I want to update the outgoings and remnant based on the previous row, like the following example:

enter image description here

Is this possible?

Upvotes: 0

Views: 188

Answers (1)

MikeAinOz
MikeAinOz

Reputation: 128

This is one way of doing it, add an index and one-line cumulative function

let
  cum_add = (x) => List.Sum(Table.SelectRows(#"Added Index", each [Index] <= x) [Remnant]), 
  Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
  #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
  #"Added Cumulative" = Table.AddColumn(#"Added Index", "Custom", each cum_add([Index] ))
in
  #"Added Cumulative"

You'll need to go into the Advanced Editor to do this

Upvotes: 1

Related Questions