Forum Discussion
Conditional Column to check If Column Blank or null then append or use non blank column
- 6 years ago
RahulPBI ,
Try this m code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDJCsMgEIbfJeccGpfYHs2maEuL0UMJeYOQW9+/IyodpDjgzPfPxmxbQy+i46xpm2h7mwGvQC9qcIPoyQg8cKQchnFMIhediOL5OY5Skf38rdOyLtN/wTmFBbBgrTUm0URm72atEdDq8Q4lloQyRkvTDDVlvO8raCGT3CuIN/pNUGpWymMwLd7jHbwxIRhTiI+9KUMnE9d4lQCLUI4H5IEvyM75+xc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ref1 = _t, Ref2 = _t, Ref3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Ref1", type text}, {"Ref2", type text}, {"Ref3", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Ref1", "Ref2", "Ref3"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","null",null,Replacer.ReplaceValue,{"Ref1", "Ref2", "Ref3"}),
#"Added Custom" = Table.AddColumn(#"Replaced Value1", "Custom", each let
_1 = if [Ref1] <> null then [Ref1] else "",
_2 = if [Ref2] <> null then [Ref2] else "",
_3 = if [Ref3] <> null then [Ref3] else "" in
_1 & " " & _2 & " " & _3),
#"Trimmed Text" = Table.TransformColumns(#"Added Custom",{{"Custom", Text.Trim, type text}})
in
#"Trimmed Text"