Forum Discussion
RWL01XOM
4 years agoNew Member
Is it possible to have a custom column reference the values of previous rows for that same column?
I'm cleaning up some data that does not have a grouping key but is grouped in order. Using the sample table below, I want to do the following for column C: Iterate through each row If A = 1 Then C...
RWL01XOM
4 years agoNew Member
This doesn't answer my exact question but it is a work around for anbody who comes across this issue in the future.
let
MaxInd = (x) => List.Sum(Table.SelectRows(G1_Col, each [A] <= x) [G1]),
Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
G1_Col = Table.AddColumn(Source, "G1", each if [A] = 1 then 1 else if [B] = "aaa" then 1 else 0),
G2_Col = Table.AddColumn(G1_Col, "G2", each MaxInd([A]))
in
G2_Col
I basically marked the begining of all the groupings with one column G1 and then summed all of the previous rows of G1 in G2. This got me to where I needed but I still would like to be able to reference previous rows of the same column if possible.