Forum Discussion
Replace value based on condition from other column
- 3 years ago
Hi goodhvnting
I believe you can still use conditional column to define one value and use "Else" clause for rest of the values.
I tried to simulate your scenario, let me know if this helps!
Input:Conditional Column:
Output:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Cheers.
- 3 years ago
You almost did it. 🙂
= Table.ReplaceValue( #"Changed Type", each if [PARK_ID] = 88 then [Campground_Name] else false, each "Chain Lakes South", Replacer.ReplaceValue, {"Campground_Name"} )Before:
After:
Full code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOz01VyM9JUSguKU1LU4rViVYywi5sjF3YwgK7uKUlCepjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PARK_ID = _t, Campground_Name = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"PARK_ID", Int64.Type}, {"Campground_Name", type text}}), #"Replaced Value" = Table.ReplaceValue( #"Changed Type", each if [PARK_ID] = 88 then [Campground_Name] else false, each "Chain Lakes South", Replacer.ReplaceValue, {"Campground_Name"} ) in #"Replaced Value" - 3 years ago
This worked perfectly. Thank you so much! I knew I was close but wouldn't have been able to get there without the help.
Cheers!
Hi goodhvnting
I believe you can still use conditional column to define one value and use "Else" clause for rest of the values.
I tried to simulate your scenario, let me know if this helps!
Input:
Conditional Column:
Output:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Cheers.
- goodhvnting3 years agoFrequent Visitor
This worked as well! Thank you!