community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE
SOLVED

Question about OR Statement

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!

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

Pulsar

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

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

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.

Pulsar

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

Alteryx Certified Partner
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
Pulsar

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
Meteoroid

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

 

Thank you!

Meteoroid

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

Labels