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.
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 code | AB | Reference | JobCode | FixedCode |
1000100 | A | ABC123 | 17PTH | |
MCA001 | B | ABC123 | 17PTH | 17PTH |
Solved! Go to Solution.
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
53 | |
21 | |
12 | |
12 |