Forum Discussion
Merge a row with the previous one
Hello,
I am new to Power BI and I struggle merging some rows.
I have rows which have a column name in it and the actual data of those columns in the next line, like this:
I want to replace those Title1 and Title2 by the actual data that's below. So far, I replaced the titles with null and renamed the columns, so it looks like that:
Now I want to merge the data with a null key with the row above.
Any idea of how to do that in Power Query?
Thanks
Hi Anonymous,
Another way (if the null for key 2 and 3 are necessary to be kept) is to use some other string (or value) that is not in the dataset as a marker instead of null when replacing the TITLE1 and TITLE2 for example 'ZZZZZ'.
Then you can fill down on the UniqueKey column.
Then you can filter out the marker text from the Table1 and Table2 columns.
4 Replies
- Greg_Deckler
Community Champion
ImkeF may have some thoughts on this but the way to reference another row in Power Query goes something like this:
=if [Index] = 0 then fnSierpinskiInit("0,1") else fnSierpinskiInit(#"Renamed Columns"{[Index]-1}[Sierpinski])Red highlighting of the important part. This is from my article here: https://www.linkedin.com/pulse/fun-graphing-power-bi-part-sqrtpowersqrt82-deckler-microsoft-mvp-/
- ImkeF
Community Champion
In this case, "Fill up" will do: check your columns (except the KeyCol) -> right click your mouse -> Fill -> Up
- MarkS
Resolver IV
Hi Anonymous,
Another way (if the null for key 2 and 3 are necessary to be kept) is to use some other string (or value) that is not in the dataset as a marker instead of null when replacing the TITLE1 and TITLE2 for example 'ZZZZZ'.
Then you can fill down on the UniqueKey column.
Then you can filter out the marker text from the Table1 and Table2 columns.
- AnonymousNot applicable
Thanks for the answers. I did a Fill down on the Key column and other columns I need.
ImkeFMaybe my exemple was not exhaustive enough, but Fill up on the columns would not work in my case because Column 4 can be null sometimes, and in that case I don't want the data to be duplicated in the line above that has a different key.