Forum Discussion
Anonymous
4 years agoNot applicable
using if(text.Contains) for multiple conditions in Power Query M
Hi there I am trying to make a custom column by using an if() statement to pass an existing column through more than one text.Contains condition, and then return a string. I have tried the be...
- 4 years ago
Anonymous
The correct syntax in Power Query would be as follows. Pay very close attention to the capitalisation as M code is entirely case-sensitive:
if Text.Contains([Product], "AB") and Text.Contains([Product], "CD") then "EF" else //your escape value goes here, like null or "Error" or similarPete
kellysolutions
2 years agoFrequent Visitor
Can Text.Contains accept a variable instead of a literal as its input?
e.g.
if Text.Contains([Product], ColumnValue) or Text.Contains([Product], "*") then blah blah blah
Thank you
BA_Pete
1 year agoSuper User
Yes, as long as the variable is a text-type scalar.
Pete