Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Malformed If Statement, combining multiple if statements

wonka1234
10 - Fireball

hi,

 

I am getting malformed if statement on the below:

 

If [FOLDER] = "Test1" OR [FOLDER] = "Test2" THEN
if Contains([n_Value],"read")
or Contains([n_value],"inquiry")
or Contains([n_value],"view")
or Contains([n_value],"no access")
or Contains([n_value],"report")
then "Yes"
else "No"
OR
If [FOLDER] = "Test3"
THEN
if Contains([n_Value],"EXEC")
or Contains([n_Value],"WRITE")
then "No"
else "Yes"
endif

 

How can I fix this?

2 REPLIES 2
chukleswk
11 - Bolide

You can use the following If formula to get the results you want

 

@wonka1234  Edit: I miss-spoke when I was talking about the nested IF Statements and after careful review and looking at @dYoast's answer, you are missing an ENDIF after that 2nd grouping of IF statements and you need to use an ELSEIF instead of that last OR.

 

Malformed If Statement.PNG

dYoast
11 - Bolide

I would split into two formula statements.

  Statement 1:  

If ([FOLDER] = "Test1" OR [FOLDER] = "Test2") AND [n_Value] IN ("read", "inquiry", "view", "no access", "report") THEN
"Yes"
else "No"
ENDIF

 

  Statement 2:  

If [FOLDER] = "Test3" AND [n_Value] IN ("EXEC", "WRITE") THEN
"No"
else "Yes"
endif

 

But, if you want to try your original, this may work:

If [FOLDER] = "Test1" OR [FOLDER] = "Test2" THEN
	if Contains([n_Value],"read")
	or Contains([n_value],"inquiry")
	or Contains([n_value],"view")
	or Contains([n_value],"no access")
	or Contains([n_value],"report")
	then "Yes"
	else "No"
	ENDIF
ELSEIf [FOLDER] = "Test3" THEN
	if Contains([n_Value],"EXEC")
	or Contains([n_Value],"WRITE")
	then "No"
	else "Yes"
	ENDIF
ELSE "Not Applicable"
endif
Labels