Short version: In PowerBI, M-language I need to extract the addresses from the column "Data" to column "Address" based on the knowledge that the address is always in the following cell of a value in the "ID" column.
Description: I have the Columns "Data" and "ID" in my dataset. I need to get the address from the column "Data" that contains a lot of random information. I know that the address is always placed in the following cell of a number in the "ID" Column. I want to extract the addresses, so they are placed next to the ID as shown in the column "Address". The amount of rows between each ID varies, and therefore I cannot do something like "extract each 6th row" or so by using index/rank etc. The data is basically structured as shown.
Tried Methods: I know I can extract this with some basic Excel-formula typing, but as this step is only one part of a long query, I would like to to this in PowerQuery/M. I've tried several solutions such as making index-columns and duplicating datasets and removing first row followed by merging the two tables and the method described here: https://www.thebiccountant.com/2018/07/12/fast-and-easy-way-to-reference-previous-or-next-rows-in-power-query-or-power-bi/.
But both seems very complex to quite a simple problem, so hopefully someone has a better solution.
Data ID Address
RandomData 1 Address_Here
Address null
RandomData null
RandomData 2 Address_Here
Address null
RandomData null
RandomData null
RandomData 3 Address_Here
Address null
RandomData null
RandomData null
RandomData null
RandomData 4 Address_Here
Address null
RandomData null
RandomData 5 Address_Here
Address null
RandomData null
RandomData null