# Alteryx Designer Discussions

The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!
SOLVED

Highlighted
6 - Meteoroid

Hi all,

I am new to Alteryx, so I am guessing this is something simple; but i cannot figure it out.  (I have tried several variations of iif and if-then, with parenthesis everywhere).  When I run these two statements independently, they each work, but when I try to run them together with an OR, everything comes back as "No".  Can someone give me some guidance?

Statement 1  -  iif (!Contains([Position], 'Center'), 'No', 'Yes')

Statement 2  -  iif (!Contains([Position], 'Operation'), 'No', 'Yes')

Combined Statement - iif (!Contains([Position], 'Center') || !Contains([Position], 'Operation'),'No', 'Yes')

Highlighted
Alteryx Certified Partner

The way the logic works here is that if either is true, then the condition is true. Try reversing your conditions like this:

IIF(Contains([Position], 'Center') || Contains([Position], 'Operation'),'Yes', 'No')

Highlighted
17 - Castor

Hi @RTD

Combining logical negations is always tricky. The formula you have only works if your input contains both Operation and Center. Anything else causes one of the or clauses to be true so the entire statement is true returning 'No'

Is this the result you want?  If you actually want it to return yes, if it contains 'Operation' or if it contains 'Center'  follow @CharlieS

Dan

Highlighted
6 - Meteoroid

It gets a little tricky because this is only part of a larger formula that I have; where if a few other conditions aren't met either it will default to "Yes".  So ideally I could use a logic like this to exclude instead of include.  Does that makes sense?  But I am open to any suggestions; i am just starting to learn.  Thank you

Highlighted
6 - Meteoroid

Oh, that is very helpful.  Thank you!  I am not sure how to get around this, as this is part of a larger formula where ultimately the default condition is "Yes".  So I want to the result to be "Yes" if it contains either Center or Operation or if it contained Center&Operation.

Highlighted
17 - Castor

If you continue using exclusionary logic, change the "||" to "&&"  meaning if it's not Operation AND it's not Center return 'No' else return 'Yes'

Dan

Highlighted
Alteryx Certified Partner
With an OR statement only one piece of the statement has to be TRUE for the
'no' to be returned.

The only way your statement will return yes is if the cell contained both
centre and operation.

Take a few examples...

Center operation FALSE FALSE = Yes

Center Bob FALSE TRUE = No

Operation Bob TRUE TRUE = No

I think you want to use the AND operator, or alternatively remove the ! And
continue to use OR.

Ben
Highlighted
17 - Castor

Since we're replying almost real time the post are showing up out of order.  Check out my post 2 above this one about changing the '||' to '&&'

Dan

Highlighted
6 - Meteoroid

That makes sense, I had my mind on "doesn't have this OR that OR that".

Thank you!

Highlighted
6 - Meteoroid

Thank you! That makes sense to me.  I switched over to &&.

Labels