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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors