Forum Discussion

Carrhill's avatar
Carrhill
Icon for Helper I rankHelper I
4 years ago
Solved

How to look at two columns with CONTAINS STRING

Hello, 

 

I need to add two conditions to a CONTAINS STRING statement but it's not working.  I'd appreciate if somebody can help please

 

It would look something like this 

 

Column = IF( CONTAINSSTRING(('Table '[Column] "A" && CONTAINSSTRING ('Table'[Column] "B") "Y", "Z" ))
 
Thank you!!
  • hnguy71's avatar
    hnguy71
    4 years ago

    Hi Carrhill ,

     

    Try this instead:

    Output = 
    VAR _FindString01 = SEARCH("ABC", [Column1], 1, 0)
    VAR _FindString02 = SEARCH("XYZ", [Column2], 1, 0)
    
    RETURN IF(_FindString01 > 0 && _FindString02 > 0, "X", "Y")

     

    Example Output:

     

3 Replies

  • Carrhill , Try like

     

    Column = IF( CONTAINSSTRING('Table '[Column] "A") || CONTAINSSTRING ('Table'[Column] "B") || CONTAINSSTRING ('Table'[Column] "Y")|| CONTAINSSTRING ('Table'[Column] "Z") )

    • Carrhill's avatar
      Carrhill
      Icon for Helper I rankHelper I

      Hey amitchandak ,

       

      Thank you!  You have solved the problem posed.   However I wasn't entirely clear in my question.

      This is my goal...

      If the column 1 contains "abc", and Column 2 contains "xyz", return X, else Y 

       

      Is there a way to do this ?  Thanks for your help!

      • hnguy71's avatar
        hnguy71
        Icon for Super User rankSuper User

        Hi Carrhill ,

         

        Try this instead:

        Output = 
        VAR _FindString01 = SEARCH("ABC", [Column1], 1, 0)
        VAR _FindString02 = SEARCH("XYZ", [Column2], 1, 0)
        
        RETURN IF(_FindString01 > 0 && _FindString02 > 0, "X", "Y")

         

        Example Output: