Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I am using rows with two types of information: devices and the serial numbers of those devices, both have same name in first column. Here is an example:
Device name | Device QR | Serial QR |
Device 1 | 00011 | |
Device 1 | S0012 | |
Device 1 | S0013 | |
Device 2 | 00022 | |
Device 2 | S0023 |
I need to fill in the empty cells in the Device QR column. In each row I have a name. Now, for each empty cell in that column, I need to find the name of its row, use that name to find another row with the same name but with a value in the cell in the Device QR column and paste that value into the empty cell in the first row.
Device name | Device QR | Serial QR |
Device 1 | 00011 | |
Device 1 | 00011 | S0012 |
Device 1 | 00011 | S0013 |
Device 2 | 00022 | |
Device 2 | 00022 | S0023 |
How can I do it?
In the Power Query editor, assuming the blank cells in DeviceQR are null, just select that column and "Fill Down". If the blanks are null strings, then replace them with null first.
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/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
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.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
29 | |
12 | |
12 | |
11 | |
8 |
User | Count |
---|---|
53 | |
28 | |
15 | |
14 | |
13 |