Join the Alteryx Community’s Maveryx Summer Cup event! Compete, network with others, and earn your gold through a series of challenges from July 24th to August 11th. Learn more about the event here.

Alteryx Designer Desktop Discussions

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

Formula IF ELSEIF ELSE does not work

IWWO
5 - Atom

Hi! 

I am struggling to find what is the problem in that simple IF statement and I would appreciate to have your help:

 

IF [Days Difference] = 'Out of scope' THEN 'Out of scope'

ELSEIF IsNull([Days Difference]) THEN 'x'

ELSEIF ToNumber([Days Difference]) <= '14' THEN 'Yes' ELSEIF 'No' ENDIF

 

The statement seems to be fine until I am entering the last value ENDIF. Before 'Formula', I used 'Sort' to be sure that 'Days Difference' column  is in V_WString format. Also, I have tried to change the second and third 'ELSEIF' to  'ELSE' but then formula does not work at all. 

 

In my data, the column 'Days Difference' contains numbers (1-30) and words for some rows (out of scope). The goal is to create a new column where numbers lower than 14 are marked as 'Yes', higher than 14 as 'No' and rows equal to 'out of scope' as 'out of scope'. 

 

Can you help to solve this?

 

Thanks in advance,

IWWO

3 REPLIES 3
binuacs
20 - Arcturus

@IWWO 

IF [Days Difference] = 'Out of scope' THEN 'Out of scope'
ELSEIF IsNull([Days Difference]) THEN 'x'
ELSEIF ToNumber([Days Difference]) <= 14 THEN 'Yes' 
ELSE 'No' ENDIF
BS_THE_ANALYST
14 - Magnetar

@IWWO I think this part of your formula is problematic:

ToNumber([Days Difference]) <= '14' 

 

You're comparing a number to a string? 

 

Lastly, the structure requires an ELSE at the end. 

 

IF -> ELSEIF -> ELSE -> ENDIF or

IF -> ELSE -> ENDIF

 

All the best,

BS

IWWO
5 - Atom

Thanks you all for your help! The issue is solved. All the best!

Labels