Forum Discussion
drogzy
4 years agoHelper I
How to replace a value in column A only based on another value in column B while in direct query
Hello, Here is what I have: Column A Column B Development Original Observation Original Development Re-entry Development Other Abandon Original Observation Orig...
- 4 years ago
Use this (Replace #"Changed Type" with your previous step)
= Table.ReplaceValue(#"Changed Type",each [Column B], each if [Column A]="Development" then "Developing" else [Column B], Replacer.ReplaceValue,{"Column B"}) - 4 years ago
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckktS83JL8hNzStR0lHyL8pMz8xLzFGK1YlW8k8qTi0qSyzJzM9Dl0LVFZSqC2QUVWKR8i/JSC0CizsmJealYJqEZIkCilwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column A" = _t, #"Column B" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column A", type text}, {"Column B", type text}}), Custom1 = Table.ReplaceValue(#"Changed Type",each [Column B], each if [Column A]="Development" then "Developing" else [Column B], Replacer.ReplaceValue,{"Column B"}) in Custom1
Anonymous
4 years agoNot applicable
Use the Custom Column by Example in Power Query to create a new column with the needed vaules
Add a column from examples - Power Query | Microsoft Docs