Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Question about OR Statement

RTD
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')

 

Thank you in Advance!

9 REPLIES 9
CharlieS
17 - Castor
17 - Castor

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')

danilang
19 - Altair
19 - Altair

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'

 

 Or Not.png

 

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

RTD
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

RTD
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.

danilang
19 - Altair
19 - Altair

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

BenMoss
ACE Emeritus
ACE Emeritus
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
danilang
19 - Altair
19 - Altair

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

RTD
6 - Meteoroid

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

 

Thank you!

RTD
6 - Meteoroid

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

Labels