Našimi kurzy prošlo více než 10 000+ účastníků
2 392 ověřených referencí účastníků našich kurzů. Přesvědčte se sami
This tutorial describes, how to get value from previous row in Power Query (or from any other row…).
There are two approaches here. The first one is shorter and uses the List.Range function. The other is longer, but you don´t have to type in M directly.
We need the animal from previous row. For example in second row there should be Hamster, which is now in the first one.
There must be an index column in table.
The syntax is like this:
Because:
After extraction it looks like this. The error in first row can be simply replaced by anything.
If you have a table like this:
and need values from previous row, like this:
How to do it?
First you need the index column:
Then add 1 (if you want to move one row back):
Then merge the table with itself. The key are the original and moved index.
Click on the doublesided arrow at the header and show the original value from connected query.
Remove the indexes and that´s all.
Comments are closed.
2 392 ověřených referencí účastníků našich kurzů. Přesvědčte se sami
Pište kdykoliv. Odpovíme do 24h
© exceltown.com / 2006 - 2023 Vyrobilo studio bARTvisions s.r.o.
Thanks for this!!!
THANK YOU. I could never think of a way to do this and I need it often!!
Thank you this is great, but I have a question. How could I show the first row? I mean the row with the result 10 in column “Value” and Blank in column “Value from Previous Row”
Is there some reason, why we can´t simply keep the first row?
this is some evil genious man. really pulled me out of a bind, thanks!
Saved my life! 🙂
Great how to. Thank you. What can I do if my table looks like
Hamster 10
Hamster 20
Hamster 30
Guinea pig 10
Guinea pig 20
Do you recommend separating the Hamster and Guinea pig first or is it possible to add a IF function?