Alteryx Designer Desktop Discussions

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

Multi-Condition IF THEN ELSE statement

PeterWard91
6 - Meteoroid

Hi all, 

 

Complete beginner to Alteryx with what I know is a straightforward problem but can't seem to complete, appreciate any help in advance. 

 

I have a column with numbers 0, 1 and 2 in and each number represents No (0), Yes (1) and Late Night Taxi Only(2). I am trying to use the below formula to change the numbers to the string. It is set to V_String. The formula only seems to break when I put in ENDIF. Suggestions?

 

IF [Claim Travel] = 0 THEN "No"
ELSEIF [Claim Travel] = 1 THEN "Yes"
ELSEIF [Claim Travel] = 2 THEN "Late Night Taxis Only"
ELSE "Error"
ENDIF

 

Thank you for your help!

P

5 REPLIES 5
Emil_Kos
17 - Castor
17 - Castor

Hi @PeterWard91,

 

Can you paste the error message? 

 

Claim travel is a numeric format?

 

This formula is set to produce a string output? 

 

 

DawnDuong
13 - Pulsar
13 - Pulsar

Hi @PeterWard91 

this could be due to the data type 

alteryx treats a string “2” as being different from a numeric 2. Also within the numeric there can be integer and decimal numbers etc.

since you are testing with the = operand, you should evaluate either a string or an integer only (double / float v prone to unexpected results and alteryx will give you warnings.

so, for the formula below to work, you need to make sure that the field [claim travel] is set to integer 

if it is string type, just need to put the numbers in inverted commas and it will work too.

 

another commonly encountered error is that you have not set whether you want to update an existing field or add a new field!

 

for newbie, highly recommend that you check out the interactive lessons - the ones for excel users and checking for mistakes are really good!

 

dawn 

 

PeterWard91
6 - Meteoroid

Thank you, see below screenshots. I am showing two formula boxes to demonstrate that the formula appears fine until I put in ENDIF. Appreciate your thoughts! 

Alteryx error 3.PNGAlteryx error 2.PNGAlteryx error.PNG

PeterWard91
6 - Meteoroid

Thank you Dawn, quote marks around the numbers worked!

DawnDuong
13 - Pulsar
13 - Pulsar

Do check out the interactive lessons, they are 2-3m per lessons and the time you save in the future Ba is N times time needed to follow those lessons (at least try the ones marked with “Core”)

Labels