Forum Discussion
Adding text to query if a condition is met
I want to add text AAB to column ID (type text) if the text value already includes letter F. I cannot seem to combine the below expresions:
If I only use this it works fine:
#"Add to name" = Table.TransformColumns(#"Renamed", {{"ID", each Text.Combine({"AAB",(_)}), type text}})
I want to add conditional statment but I am falling short. What I would want to achive:
each if Text.Contains([ID], "F") then [execute the above] else null)
I am trying:
= if Text.Contains({#"Renamed, {"ID"}}, "F") then (Table.TransformColumns(#"Renamed", {{"ID", each Text.Combine({"AAB",(_)}), type text}})) else null
but getting expression error (list not convertable to text)
Hi davidz106 ,
Please try this := Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([ID],"F") then [ID] & "AAB" else null)
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
1 Reply
- rohit_singhSolution Sage
Hi davidz106 ,
Please try this := Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([ID],"F") then [ID] & "AAB" else null)
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂