Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Using Contains In a IF Statement

jeep32mudtaman
5 - Atom

Hello,

 

When I use Contains in an IF statement do I need to include  =-1 to ensure I only get entries where the statement is true?  I know that if I'm looking for anything that is false I would need =0.   However, I don't know if the  =-1 is just overkill or if it is really needed.  Would the 2 examples below yield the same results?

 

Here is an example of what I'm talking about

 

IF Contains("ABC123", [letters]) = -1 THEN "Awesome" ELSE "Shucks" ENDIF

IF Contains("ABC123", [letters])  THEN "Awesome" ELSE "Shucks" ENDIF

 

1 REPLY 1
Thableaus
17 - Castor
17 - Castor
Hi,

The Contains function returns True and False values, so, you basically don't need to make It explicit like you're saying.

Another way to force a false statement would be using the exclamation (!) sign.

For example,

IF !Contains([letters], "ABC123") THEN "Awesome" ELSE "Shucks" ENDIF

This basically means "If the field letters does not contain ABC123, then return Awesome.

Another thing you should consider is that the field comes First, your target comes Second. So switch positions in your contains expression to make It work properly.

Cheers,
Labels