Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Theiamania
Frequent Visitor

Row with an empty cell, find another row with the same name but with that cell and copy the value

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 nameDevice QRSerial QR
Device 100011 
Device 1 S0012
Device 1 S0013
Device 200022 
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 nameDevice QRSerial QR
Device 100011 
Device 100011S0012
Device 100011S0013
Device 200022 
Device 200022S0023

 

How can I do it?

3 REPLIES 3
ronrsnfld
Super User
Super User

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.

tackytechtom
Super User
Super User

Hi @Theiamania ,

 

How about this:

 

Before:

tackytechtom_0-1666371572585.png

 

After

tackytechtom_1-1666371592115.png

 

 

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! 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 nameDevice QRSerial QR
Device 100011 
Device 1 S0012
Device 1 S0013
Device 200022 
Device 2 S0023
Device 300033 
Device 400044 
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.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors