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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
wjeanes
Advocate III
Advocate III

Update a blank row if two rows in another column match

Not sure if this is the right place to get help on something like this but here goes.

 

This seems so simple yet I'm completely stuck.  Essentially all I want to do is populate the custom Column "Fixed Code" with the value in JobCode wherever the Reference column matches.

 

This needs to be done in Powery Query though not as a calculated column in Dax as only the A rows would be used throughout the datamodel and B rows would be filtered out after the custom column has been populated.

 

Item codeABReferenceJobCodeFixedCode
1000100AABC123 17PTH
MCA001BABC12317PTH17PTH
1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.  The key is to replace your blanks with nulls to get the fill down to work.  Your sample data had a space, but adapt the Replaced Value step for your actual data.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMABiJR0lRxB2cjY0MgYyFJRidaKVfJ0dgbJArhOynKF5QIiHUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Item code" = _t, AB = _t, Reference = _t, JobCode = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item code", type text}, {"AB", type text}, {"Reference", type text}, {"JobCode", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ",null,Replacer.ReplaceValue,{"JobCode"}),
    #"Sorted Rows" = Table.Sort(#"Replaced Value",{{"JobCode", Order.Descending}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Sorted Rows", "JobCode", "Fixed Code"),
    #"Filled Down" = Table.FillDown(#"Duplicated Column",{"Fixed Code"})
in
    #"Filled Down"

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

1 REPLY 1
mahoneypat
Microsoft Employee
Microsoft Employee

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.  The key is to replace your blanks with nulls to get the fill down to work.  Your sample data had a space, but adapt the Replaced Value step for your actual data.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMABiJR0lRxB2cjY0MgYyFJRidaKVfJ0dgbJArhOynKF5QIiHUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Item code" = _t, AB = _t, Reference = _t, JobCode = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item code", type text}, {"AB", type text}, {"Reference", type text}, {"JobCode", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ",null,Replacer.ReplaceValue,{"JobCode"}),
    #"Sorted Rows" = Table.Sort(#"Replaced Value",{{"JobCode", Order.Descending}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Sorted Rows", "JobCode", "Fixed Code"),
    #"Filled Down" = Table.FillDown(#"Duplicated Column",{"Fixed Code"})
in
    #"Filled Down"

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors