Forum Discussion
Row with an empty cell, find another row with the same name but with that cell and copy the value
Hi Theiamania ,
How about this:
Before:
After
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wckkty0xOVTBU0lEyMDAwBNEKSrE6KBIKQBwMlDTCJWGMLGEEMcrICN0oI4QOI6COWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Device name" = _t, #"Device QR" = _t, #"Serial QR" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Device name", type text}, {"Device QR", Int64.Type}, {"Serial QR", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Device QR] <> null)),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Device name"}, #"Filtered Rows", {"Device name"}, "Filtered Rows", JoinKind.LeftOuter),
#"Removed Columns" = Table.RemoveColumns(#"Merged Queries",{"Device QR"}),
#"Expanded Filtered Rows" = Table.ExpandTableColumn(#"Removed Columns", "Filtered Rows", {"Device QR"}, {"Filtered Rows.Device QR"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Filtered Rows",{{"Filtered Rows.Device QR", "Device QR"}}),
#"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Device name", "Device QR", "Serial QR"})
in
#"Reordered Columns"
I'd suggest you use that code and have a look into the APPLIED STEPS on the right to see what I have done. Essentially, I filered only the rows that do not have NULLs in Device QR. I then joined that table with the original table. From there, it was just some cosmetics like dropping the original column, expanding the Device QR column from the merged table, renaming and finally some reordering.
Let me know if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
- Theiamania3 years agoFrequent Visitor
Thanks tackytechtom
Your solution works but generates new rows that did not originally exist. These new rows appear to be all Devices but they don't have any other Serial rows with the same 'Device name'.
Sorry, I didn't think that point was relevant and didn't specify it above. I leave an example below of what the table originally looks like.
Device name Device QR Serial QR Device 1 00011 Device 1 S0012 Device 1 S0013 Device 2 00022 Device 2 S0023 Device 3 00033 Device 4 00044 Device 4 S0045 This duplicity is created in the 'Expanded Filtered Rows' step. But, from what you say and as I didn't specify the above detail, I think it makes the whole process approach no longer valid. Is this the case?
I am very grateful for your time.