Forum Discussion
wjeanes
Advocate III
4 years agoUpdate 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 "F...
- 4 years ago
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
mahoneypat
Microsoft Employee
4 years agoHere'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