Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

IF ELSEIF ENDIF not working

JenT
5 - Atom

JenT_0-1684245478257.png

IF [household_income] < 10000 THEN '00: Less than $10,000'
ELSEIF [household_income] >= 10000 AND [household_income] < 15000 THEN '01: $10,000 - $14,999'
ELSEIF [household_income] >= 15000 AND [household_income] < 20000 THEN '02: $15,000 - $19,999'
ELSEIF [household_income] >= 10000 AND [household_income] < 25000 THEN '03: $20,000 - $24,999'
ELSEIF [household_income] >= 25000 AND [household_income] < 30000 THEN '04: $25,000 - $29,999'
ELSEIF [household_income] >= 30000 AND [household_income] < 35000 THEN '05: $30,000 - $34,999'
ELSEIF [household_income] >= 35000 AND [household_income] < 40000 THEN '06: $35,000 - $39,999'
ELSEIF [household_income] >= 40000 AND [household_income] < 45000 THEN '07: $40,000 - $44,999'
ELSEIF [household_income] >= 45000 AND [household_income] < 50000 THEN '08: $45,000 - $49,999'
ELSEIF [household_income] >= 50000 AND [household_income] < 60000 THEN '09: $50,000 - $59,999'
ELSEIF [household_income] >= 60000 AND [household_income] < 75000 THEN '10: $60,000 - $74,999'
ELSEIF [household_income] >= 75000 AND [household_income] < 100000 THEN '11: $75,000 - $99,999'
ELSEIF [household_income] >= 100000 AND [household_income] < 125000 THEN '12: $100,000 - $124,999'
ELSEIF [household_income] >= 125000 AND [household_income] < 150000 THEN '13: $125,000 - $149,999'
ELSEIF [household_income] >= 150000 AND [household_income] < 200000 THEN '14: $150,000 - $200,000'
ELSEIF [household_income] >= 200000 THEN '14: $200k+'
ELSE '15: Unknown'
ENDIF

4 REPLIES 4
binuacs
20 - Arcturus

@JenT Seems to be your field  [household_income] is numeric in type and you are updating it to a string type,

ArtApa
Alteryx
Alteryx

@JenT - It is the other way around. Your field [household_income] is a string data type and you try to compare the string against numeric values. The solution would be to create a new, numeric field which you will use for comparison, or use tonumber([household_income]) in your conditional statement.

 

Here is an example, if your field  [household_income] is numeric. As you can see, no problems there:
 

ArtApa_0-1684392753844.png

 

If I change it to string, I have the same problem:

ArtApa_1-1684392799214.png

 

Qiu
20 - Arcturus
20 - Arcturus

@JenT 
I agree with others that your data type might be the cause.
For this kind of issue, I usually choose to use a look up table for flexibility and clearity, if the dataset if not too huge.

0518-JenT.PNG

emartinez
5 - Atom

Did you end up figuring it out? I'm having the same type of issue. 

Labels