Forum Discussion
Anonymous
4 years agoNot applicable
Replace values in multiple columns with conditional
HI Community, hope you can help me. i want to do a replace value text in more than two columns based on a condition. if null = NO else YES but the formula does not work can you help?? ...
Anonymous
4 years agoNot applicable
Hi Anonymous ,
I think it's difficult to do such replacement in a single step.
Below is my whole M syntax:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRCjAEEUZKsToILiYHogpKYBVAlzeCGIssj7AILIGdGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value1" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Column1", "Column2", "Column3"}),
#"Replaced Value" = Table.ReplaceValue(#"Replaced Value1",null,"No",Replacer.ReplaceValue,{"Column1", "Column2", "Column3"}),
#"Added Index" = Table.AddIndexColumn(#"Replaced Value", "Index", 1, 1, Int64.Type),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Index"}, "Attribute", "Value"),
#"Replaced Value2" = Table.ReplaceValue(#"Unpivoted Other Columns", each [Value], each if [Value] <> "No" then "Yes" else [Value],Replacer.ReplaceValue,{"Value"}),
#"Pivoted Column" = Table.Pivot(#"Replaced Value2", List.Distinct(#"Replaced Value2"[Attribute]), "Attribute", "Value")
in
#"Pivoted Column"
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous4 years agoNot applicable
Hi,
i need to do it in the Query Editor and i can not traspose anythin as the table contains many columns with more info.Shall be do ine straigh away in the the table of the query with some simple step replacing values