I am relatively new to PQ and don't want to do it in DAX (lack of understanding as to how to move between the 2, and the final result is an Excel Table), I feel that I am now getting absolutely no where. All I am trying to do is read the total from the previous record. I do not want to do another index and join, so I thought I would go for a list.range, but having looked it up I cannot for the life of me get it to work. Utter Despair!! The code I have tried (the column is called Calc). is below:
= Table.AddColumn(#"Reordered Columns", "Custom", each List.Range(Source[Calc],[Index.1]-1,1)) and I get a column of errors
Expression.Error: The column 'Calc' of the table wasn't found.
Details:
Calc
So I took out source and did the following:
= Table.AddColumn(#"Reordered Columns", "Custom", each List.Range({[Calc]},[Index.1]-1,1))
The first value shows the total for the current row and all the other values are blank. I was hoping to pick up the previous row. I expect the 1st value to be an error but the rest should work I would have thought
Please tell me what or where I am going wrong.
Thank you in advance.[Image Can Not Be Found]
Hi Chris,
To get the previous row value, you have more options.
One of them is to add 2 index columns: one starting from 0, and the other one starting from 1.
Next step is to merge the current table with itself, with the 2 index columns set as keys (use one index for first table, and the second index for the second table)
This will create the offset of 1 row you need, you will be able to bring the previous row value into the current row, by expanding the Calc column from the merge.
But if you're after a running total, you're not on the right track, adding a column with the following formula might help:
=List.Sum(List.FirstN(#"Added Index"[Number],[Index]))
Hi Catalin,
Apologies for not coming back earlier and thank you for taking the time to answer. I was not keen on indexing as this is slowing down PQ hugely. I ended up using the SUMIF in excel after running the extract. It worked as was simple. I was trying to do it all in PQ, but it was taking toooo much time.