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.

multiple if elseif statements

SouravKayal
8 - Asteroid

Hi Folks,

 

SO i have a requirement where i have two fields one in the data and one that comes from an externa file which is appended to the data. I need to check both and make the formula field

 

Fields are Source System and Count.

 

So this calculated field will display based on the above condition. I have Jan - Dec Count in the data. and three data sources A, B and C/

 

So i want to do like if [source] ="A" and [count]= 1 then [JanA] elseif  [source] ="A" and [count] =2 then [FebA] elseif  [source] ="B" and [count] =1 then [Janb] elseif  [source] ="B" and [count] =2 then [Febb] elseif [source]= "C" and [count] = 1 then [Janc] elsif elseif  [source] ="C" and [count] =2 then [FebC] else 0 endif

 

But I am not getting the desired output, getting all 0

5 REPLIES 5
Emil_Kos
17 - Castor
17 - Castor

Hi @SouravKayal,

 

If I could advise you something in this case don't use the if-else statement. Create a table that contains all the rules that you have mentioned and use the join tool. 

 

It will be easier for you to maintain and in case it will stop working you will be able to easily fix it. 

 

 

SouravKayal
8 - Asteroid

But what about the multiple conditions

Emil_Kos
17 - Castor
17 - Castor

Hi,


You can use this table to join your data:

 

Source Count New col
A 1 JanA
B 2 FebA
B 1 JanB
B 2 FebB
C 1 JanC
C 2

FebC

 

everything that wasn't joined should have new column equal to 0. 


It will be also easier for you to understand which positions aren't joining as expected and it will be easier for you to correct.

 

I am not sure why your multiple IF not works but I did my best to recreate your logic. 

 

 

SouravKayal
8 - Asteroid

OK the table will have the condtions but the column is already there in the data. For ex Jan A, Feb B etc how will i get those in the table

Qiu
20 - Arcturus
20 - Arcturus

@SouravKayal 

Dont forget old friend "Transpose".

Following idea of @Emil_Kos  and I agree that it is better to avoid lengthy else if statement.

0201-SouravKayal.PNG

Labels