Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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...
  • BA_Pete's avatar
    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 similar

     

    Pete