Forum Discussion
DataLife321
2 years agoFrequent Visitor
IF Statement to return on same row depending on condition
Hi All, Can someone please help to see if this is possible in the Power Query Custom Column, I am trying to get the result to show in the same row but not sure how to add a concatenation &"-"& so w...
- Anonymous2 years ago
Hi DataLife321
You can try the following code in advanced editor in power query.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PLUjMqzRU0lGKRMGxOnBJIzRJZDljZHE0fSbI4mhypsjiYLlYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, Column1 = _t, CompanySA = _t, CompanyMS = _t, CompanyFE = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Column1", type text}, {"CompanySA", type text}, {"CompanyMS", type text}, {"CompanyFE", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let a=if [CompanySA]="Y" then "CompanySA" else "", b=if [CompanyMS]="Y" then "CompanyMS" else "", c=if [CompanyFE]="Y" then "CompanyFE" else "" in if [Customer]="Company1"and [Column1]="Y" and a<>"" then a&" "&b&" "&c else if [Customer]<>"Company1"and [Column1]="Y" and a<>"" then a&" "&b else null) in #"Added Custom"Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
2 years agoNot applicable
Hi DataLife321
You can try the following code in advanced editor in power query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PLUjMqzRU0lGKRMGxOnBJIzRJZDljZHE0fSbI4mhypsjiYLlYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, Column1 = _t, CompanySA = _t, CompanyMS = _t, CompanyFE = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Column1", type text}, {"CompanySA", type text}, {"CompanyMS", type text}, {"CompanyFE", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let
a=if [CompanySA]="Y" then "CompanySA" else "",
b=if [CompanyMS]="Y" then "CompanyMS" else "",
c=if [CompanyFE]="Y" then "CompanyFE" else ""
in if [Customer]="Company1"and [Column1]="Y" and a<>"" then a&" "&b&" "&c else if [Customer]<>"Company1"and [Column1]="Y" and a<>"" then a&" "&b else null)
in
#"Added Custom"
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
DataLife321
2 years agoFrequent Visitor
Great stuff mate thank you.. Managed to use this to get it working appreciate it