Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

Required help in IF Statement

anonymous008_G
8 - Asteroid

Hi,

I am trying to create new column based on my below condition. however, this is not working in formula tool. Can someone please help me correcting the IF statement.

 

IF Contains([Period], "One YearEnded") then "Cumulative" ELSEIF Contains([Period], "_2" and "One YearEnded") then "Annulized"
ELSE "Annulized" ENDIF

 

(Screenshot attached)

16 REPLIES 16
alexnajm
17 - Castor
17 - Castor

Your screenshot doesn’t end with ENDIF!

alexnajm
17 - Castor
17 - Castor

But also you need to separate your contains statement - Contains([Period], “_2”) OR Contains([Period], “One YearEnded”)

 

IF Contains([Period], "One YearEnded") then "Cumulative" ELSEIF Contains([Period], “_2”) OR Contains([Period], “One YearEnded”) then "Annulized"
ELSE "Annulized" ENDIF

aatalai
14 - Magnetar

been there done that

aatalai
14 - Magnetar

 

@alexnajm couldn't the if statement be IF Contains([Period], "One YearEnded") then "Cumulative"
ELSE "Annulized" ENDIF

 

as at the orginal esle if either way it would be "Annulized" - your way would work, but this would just be a bit more efficent?

anonymous008_G
8 - Asteroid

Hi Alex --- thanks for this. Now the conditional formula working fine but end result is not as expected. In my column there are values One YearEnded12/31/23 and One YearEnded12/31/23_2. I want to differentiate this as Cumulative and Annualized respectively.  However, using your corrected formula I get both as Cumulative. Could you please help further. I even try replacing OR with AND but this doesn't worked.

anonymous008_G
8 - Asteroid

Thanks for your input but this way also not fulfilling my end goal as explained to Alex in my recent comment. 

alexnajm
17 - Castor
17 - Castor

@aatalai yes I agree that would work and be simpler - I just worked on correcting what was in front of me 😊

 

@anonymous008_G thats correct - that's because your original IF statement doesn't differentiate between the One YearEnded values. Why can't you just do IF Contains([Period],"_2") THEN "Annualized" ELSE "Cumulative" ENDIF ?

aatalai
14 - Magnetar

@alexnajm team work makes the dream work

 

anonymous008_G
8 - Asteroid

Apologies for providing limited information earlier, but your recent solution also wouldn't work since column contains few other values as well as per below table. My expected output to be all the values which contain "One Year Ended" in period column should be populated as cumulative in the new column and rest other should populate as Annualized including the one "One "YearEndedMM/DD/YY_2". 

 

PeriodReturn Type
One YearEnded12/31/23Cumulative
One YearEnded12/31/22Cumulative
One YearEnded12/31/21Cumulative
One YearEnded12/31/20Cumulative
One YearEnded12/31/19Cumulative
One YearEnded12/31/18Cumulative
One YearEnded12/31/17Cumulative
One YearEnded12/31/16Cumulative
One YearEnded12/31/15Cumulative
One YearEnded12/31/14Cumulative
One YearEnded12/31/23_2Cumulative
Two YearsEnded12/31/23Annulized
Three YearsEnded12/31/23Annulized
Four YearsEnded12/31/23Annulized
Five YearsEnded12/31/23Annulized
Ten YearsEnded12/31/23Annulized

 

Labels