How to add additional options to CONTAINS

Hello!
I am trying to figure out how to add more than one option for CONTAINS.
Here is what I currently have, I definitely have a very low understanding of the logic for formulas:
CONTAINS([Day Notes], โ€œcrockโ€ ) CONTAINS([Day Notes], โ€œusbโ€) CONTAINS ([Day Notes], โ€œtradeโ€)

It doesnโ€™t need to contain all phrases, just one or the other or multiple. Iโ€™m using this for a format rule.

Thanks in advance

Solved Solved
0 17 270
1 ACCEPTED SOLUTION

@WillA108
Do you want
OR(CONTAINS([Day Notes], โ€œcrockโ€ ),([Day Notes] = โ€œusbโ€), ([Day Notes]= โ€œcoolerโ€))

or this

OR(CONTAINS([Day Notes], โ€œcrockโ€ ),CONTAINS([Day Notes], โ€œusbโ€),CONTAINS([Day Notes],โ€œcoolerโ€))

NOT TESTED
I removed the extra parenthisis before the second CONTAINS and a space. Does that still work?

View solution in original post

17 REPLIES 17

Hi @WillA108
Check out OR()

Steve
Platinum 4
Platinum 4

For reference:

Yah I took a look at this, I still canโ€™t figure out how to combine OR with CONTAINS.
Can you please give an example of how to give multiple options in a CONTAINS expression?
Thanks โค๏ธ

Iโ€™ve tried CONTAINS([Day Notes], โ€œcrockโ€ ) OR (โ€œusbโ€) OR (โ€œcoolerโ€)
and i have tried CONTAINS([Day Notes], โ€œcrockโ€ ) OR CONTAINS([Day Notes], โ€œusb")
Also CONTAINS([Day Notes], โ€œcrockโ€ ) OR ([Day Notes], โ€œusbโ€)
and also CONTAINS([Day Notes], โ€œcrockโ€ OR โ€œusbโ€ OR โ€œcoolerโ€)

@WillA108
OR(([Color] = "Red"), ([Color] = "Yellow"), ([Color] = "Green")) : TRUE if the Color column value is any of Red , Yellow , or Green . Equivalent to IN([Color], {"Red" "Yellow", "Green"}) . See also IN() .

I appreciate the responses but this is really all greek to me, as it doesnโ€™t show me how to combine it with CONTAINS.
For example I tried CONTAINS([Day Notes], โ€œcrockโ€ )OR([Day Notes] = โ€œusbโ€), ([Day Notes]= โ€œcoolerโ€)) and it will only light up daynotes which contain โ€œcrockโ€ still when I made the formatting to turn the sentence green.

@WillA108
Do you want
OR(CONTAINS([Day Notes], โ€œcrockโ€ ),([Day Notes] = โ€œusbโ€), ([Day Notes]= โ€œcoolerโ€))

or this

OR(CONTAINS([Day Notes], โ€œcrockโ€ ),CONTAINS([Day Notes], โ€œusbโ€),CONTAINS([Day Notes],โ€œcoolerโ€))

NOT TESTED
I removed the extra parenthisis before the second CONTAINS and a space. Does that still work?

Once I added the appropriate amount of parenthesis the second formula worked.

OR(CONTAINS([Day Notes], โ€œcrockโ€ ),(CONTAINS([Day Notes], โ€œusbโ€), (CONTAINS([Day Notes],โ€œcoolerโ€))))

Thanks Lynn!

It is now working for crock and usb but not cooler or anything else.

OR(CONTAINS([Day Notes], โ€œcrockโ€ ),(CONTAINS([Day Notes], โ€œusbโ€), (CONTAINS([Day Notes],โ€œCoolerโ€), (CONTAINS([Day Notes],โ€œtradeโ€), (CONTAINS([Day Notes],โ€œbrokenโ€), (CONTAINS([Day Notes],โ€œroom and coldโ€), (CONTAINS([Day Notes],โ€œroomโ€), (CONTAINS([Day Notes],โ€œcoldโ€), (CONTAINS([Day Notes],โ€œr+cโ€), (CONTAINS([Day Notes],โ€œh+cโ€), (CONTAINS([Day Notes],โ€œhotโ€), (CONTAINS([Day Notes],โ€œreplaceโ€), (CONTAINS([Day Notes],โ€œpumpโ€), (CONTAINS([Day Notes],โ€œnew customerโ€), (CONTAINS([Day Notes],โ€œtapโ€),(CONTAINS([Day Notes],โ€œbringโ€) ))))))))))))))))

Hi Lynn,

In your edited second expression, is it possible to do the same with NOT(CONTAINS()? The error I get is the following:

ERROR: Condition NOT(CONTAINS([Comment],"crock")) has an invalid structure: no more than 1 subexpression(s) allowed

Was just wondering if there was an expression in Appsheet that would allow for multiple needles in one haystack. 

 

The problem is not with your NOT(CONTAINS(...)) expression, it's where you're using it. Please post a screenshot of the entire expression and error message.

Hi, Thanks for the reply but I was able to get an answer and figured it out:

NOT(OR(CONTAINS([Comment], "value"), contains([Comment],"value2"), contains([Comment],"value3"), contains([Comment],"value4"), contains([Comment],"value5")))

It would be nice though to have a separate table with the restricted words and just reference them.

There is another expression offered by a friend, that works with a separate table, but there's some limitation where punctuation affects the outcome because it's not using Contains()

COUNT(INTERSECT(SPLIT([Comment], " "),  Not Accepted[Word])) = 0

If you understand it and could offer feedback, it would be appreciated! 


Hi @WillA108
I didnt test but i dont think you need all of those parenthisis. I have edited my second expression.

It kept adding them until it stopped coming up with an error. I thought it was odd too haha

It seems like it works, thank you!

Top Labels in this Space