Alteryx Designer Desktop Discussions

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

Multiple if statements

crispyrelic
5 - Atom

Hi All

 

I need some guidance on Multiple if statements i currently have in Tableau but need to bring the calculation in to Alteryx.

below is an example of the syntax:

if [Account ID]='1'
or [Account ID]='2'
or [Account ID]='3'
or [Account ID]='49'
or [Account ID]='776'
or [Account ID]='65'
or [Account ID]='989'
or [Account ID]='88'

then (if
[Centre ID]='PC'
or [Centre ID]='RIN'


then (if
[ProductStructure]='SRE'
or [ProductStructure]='NLL'
or [ProductStructure]='HER'
or [ProductStructure]='RIN'

 

Then (if
[Channel]='Internal'

 

then 'Result'
end)
end)
end)
end

 

I have tried the if then elseif then endif and it does not give me the correct results. 

 

Thanks in advance. 

5 REPLIES 5
MarqueeCrew
20 - Arcturus
20 - Arcturus

I'd recommend learning IN statements.

 

IN ('1', '2', '3a') 

 

they are faster to type....

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
jzkyburz
8 - Asteroid

@crispyrelic , have you looked into using a switch statement? You could use a combination of an 'IF' statement along with a switch to accomplish what you're looking for:

 

Switch(Value,Default,Case1,Result1,...,CaseN,ResultN)

 

I also find it useful to use IIF for if statements:

 

IIF(bool, if true, if false)

DataNath
17 - Castor

@crispyrelic unlike in Tableau, where you can just END a statement and that will default to 'else null end' if there's no elseif in between, in Alteryx you have to specifically define this. Because of that, you then need to end the if statement at each level with it being nested. Without any mock data and expected outcome to test this on, I'm more having a stab at what I think this ought to be. How do you get on with this? If you still have no luck, some records and what they should return would be great so we can test and diagnose this:

 

if [Account ID] in ('1','2','3','49','776','65','989','88')

then if
[Centre ID] in ('PC','RIN')

then if
[ProductStructure] in ('SRE','NLL','HER','RIN')

Then if
[Channel]='Internal'

then 'Result'

else null()
endif
else null()
endif
else null()
endif
else null()
endif

 

I've also tidied this up a little with the IN function as mentioned by @MarqueeCrew - which is also available in Tableau.

crispyrelic
5 - Atom

Thanks all and Data Nath, that seems to do the trick.

DataNath
17 - Castor

No problem @crispyrelic. If you need any further help/explanation then please do shout up. If not, feel free to mark the solution so that others with the same issue can easily find it!

Labels