Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Need assistance with an extensive "If" statement which involves two separate columns

JoshuaElphee
8 - Asteroid

I am utilizing "formula" to add a new column which will state "Y" or "N" based on logic:

 

if([award basis] = "Competitive" or "Open Competitive" and (!contains[Billing Method], "CP" or "TM" or "LH")
then "Y"
Else "N"
Endif

 

The logic is if award basis is either "Competitive or open competitive, and the field billing method does not contain "CP" "TM" or "LH", the new field should show "Y", otherwise "N".

 

This breaks after the "and" statement.

4 REPLIES 4
ChrisTX
16 - Nebula
16 - Nebula

Check the Functions (alteryx.com) page for syntax examples

 

Try this:

 

if [award basis] IN ("Competitive", "Open Competitive")  and !contains([Billing Method], "CP") and  !contains([Billing Method], "TM") and !contains([Billing Method], "LH")

 

 

alexnajm
18 - Pollux
18 - Pollux

if([award basis] = "Competitive" or [award basis]="Open Competitive") and (!contains([Billing Method], "CP") or !contains([Billing Method],"TM") or !contains([Billing Method],"LH")
then "Y"
Else "N"
Endif

Raj
16 - Nebula

@JoshuaElphee Just a bit of Structuring and your formula will be working.

IF([award basis] = "Competitive" OR [award basis]="Open Competitive")

And (!contains([Billing Method], "CP")
OR !contains([Billing Method],"TM")
OR !contains([Billing Method],"LH")
THEN "Y" Else "N"
Endif

ChrisTX
16 - Nebula
16 - Nebula

👆 This syntax is missing parenthesis around the multiple Contains functions, which may produce unexpected results when mixing AND and OR.

Labels
Top Solution Authors