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.
SOLVED

IF THEN ELSEIF Statement

nicktekippe
8 - Asteroid

I am trying to create a score 1-8 for my data using a Formula tool with an IF statement. It makes sense to me and I feel like it should work but once I add the ENDIF at the end of the statement it invalidates the last line of code. If somebody knows how to fix this code or has a better way to do this I'm all ears.

nicktekippe_0-1660233054721.png

nicktekippe_1-1660233062322.png

 

2 REPLIES 2
DataNath
17 - Castor

Hey @nicktekippe, within the expression you're trying to apply numerical functions (like >=, = etc) to strings as you're wrapping the numbers in quotes. If you make sure that R12 IP is a numeric data type and then remove all of the quotes around the values you're checking like '0', '1', '60' then that should help.

MarqueeCrew
20 - Arcturus
20 - Arcturus

@nicktekippe ,

 

Let's keep it simple....

 

 

IF
[R12 IP] = 0     THEN '0'     ELSEIF
[R12 IP] < 60    THEN '1'     ELSEIF
[R12 IP] <120    THEN '2'     ELSEIF
[R12 IP] <180    THEN '3'     ELSEIF
[R12 IP] <240    THEN '4'     ELSEIF
[R12 IP] <300    THEN '5'     ELSEIF
[R12 IP] <360    THEN '6'     ELSEIF
[R12 IP] <420    THEN '7'     ELSEIF
ELSE
'8'
ENDIF

 

 

 

Note:  This assumes that you've turned incoming data into NUMBER types.

 

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels