Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Multiple AND and CONTAINS in IF THEN Statement

danielasmith
5 - Atom

Hi All,

 

In the Formula Tool I'm trying to use the following IF THEN statement to update BRAND but it's not working properly.  X and Z are changed to "ALL STILL XLIC":

 

if !CONTAINS([BRAND],"X") && contains([CARBONATION],"NON") && contains([TYPE],"XLIC")
then "ALL STILL XLIC"
ELSEif !CONTAINS([BRAND],"Z") && contains([CARBONATION],"NON") && contains([TYPE],"XLIC")then "ALL STILL XLIC"
else [BRAND] endif

 

Is it not possible to have three conditions in the  statement?  

3 REPLIES 3
JohnJPS
15 - Aurora

I would put parentheses around certain things I want to segregate....

IF (!contains(......)) && etc....

Does that help?  If so, then we've learned something about Alteryx's order of operations.

mmenth
11 - Bolide

Hi @danielasmith,

 

Think about it this way, your X is passing through your first if statement, but it is being caught in your elseif statement, and is therefore label 'ALL STILL XLIC'. Similarly, your Z is being caught in the first if statement. I think what you really want is to have all four conditions in one line: 

 

if !CONTAINS([BRAND],"X") && !CONTAINS([BRAND],"Z") && contains([CARBONATION],"NON") && contains([TYPE],"XLIC")
then "ALL STILL XLIC"

else [BRAND] endif

 

Best,

mmenth

danielasmith
5 - Atom

Thanks!  I am trying this now!  Will let you know if it works.  

Labels
Top Solution Authors