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

If Column is X or Y AND another column is Z then put an"X" Else leave it blank

NicoleMA
7 - Meteor

I am trying to write an expression to look at two columns in my file. The first column can meet two criteria (Daily or Weekly) then second column can only say Sunday. I have tried many variations and most often the error says it can't end with an operator.

I googled and found II looking thing that I think can be used for the OR but it still isn't right.

 

Here is my latest try:

IFContains([Product Type],"DAILY")||contains([Product Type],"Weekly") && ([Insert Day],"Sunday")
THEN "X" Else "" ENDIF

 

Any help would be great!!

Thanks!

3 REPLIES 3
jdunkerley79
ACE Emeritus
ACE Emeritus

Try: 

IF (Contains([Product Type],"DAILY") || Contains([Product Type],"Weekly")) && ([Insert Day] = "Sunday")
THEN "X" 
ELSE "" 
ENDIF

I am not sure of the precedence order of || vs && in Alteryx but expect it follows the C++ order so && is processed before ||. To get round this you need to bracket the || conditions.

 

(I am not in front of Alteryx so possible mistake in formula!)

NicoleMA
7 - Meteor

Worked perfectly!! Thanks so much!

I guess one of the things I didn't get is the Day = Sunday. I didn't do the equals! How do you know to do that since the other two only used a comma?

jdunkerley79
ACE Emeritus
ACE Emeritus
The others are being done as parameters to the contains function. Contains is looking for it being part of the string and returns true if found and false otherwise. 
If they are exact matches then you could use the = or use IN to match in a list. 
Get Outlook for iOS
Labels
Top Solution Authors