Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
davidz106
Helper II
Helper II

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)

 

1 ACCEPTED SOLUTION
rohit_singh
Solution Sage
Solution Sage

Hi @davidz106 ,

Please try this : 

rohit_singh_0-1656454378435.png

= 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! 🙂

View solution in original post

1 REPLY 1
rohit_singh
Solution Sage
Solution Sage

Hi @davidz106 ,

Please try this : 

rohit_singh_0-1656454378435.png

= 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! 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors