Free Trial

Alteryx Designer Desktop Discussions

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

Something missing in formaula

Kamran1991
11 - Bolide

if [Fun Score]<1 then "LIFE CHANGING!" elseif
if [Fun Score]>1 then "AMAZING" elseif
if [Fun Score]>2 then "Great!" elseif
if [Fun Score]>3 then "Fun" elseif
if [Fun Score]>4 then "Pretty Good" elseif
if [Fun Score]>5 then "Feeling Weird" elseif
if [Fun Score]>6 then "Dizzy" elseif
if [Fun Score]>7 then "Sick" elseif
if [Fun Score]>8 then "Really Sick" else
"Refund" endif

 

Can anyone let me know what is wrong in this formula ?

 

Thanks,

Kamran

10 REPLIES 10
Rana_Kareem
9 - Comet

@Kamran1991..

 

Another thing I'd add.. you need to change the order of conditions!

Order it descending not ascending.

Because with this expression you'll get only two results "LIFE CHANGING" and "AMAZING" and that's not right

 

That's because IF Statement will just take the first conditions that are met.

 

In your case:

IF [Fun Score] < 1 THEN "LIFE CHANGING!"

Will check if the condition is met then it will return the result, no problem with that.

 

 

Then, it will check if the following condition is met and will return the result..

ELSEIF [Fun Score] > 1 THEN "AMAZING"

 

After that it will stop checking, it won’t check this condition:

ELSEIF [Fun Score] > 2 THEN "Great!"

 

Because the previous condition said if the Score is more than 1 then return ‘AMAZING’ , So, all the following conditions will be ignored, because all the remaining Scores are above 1 !!

 

To correct your expression, you need to rearrange the conditions to be like this:

IF [Fun Score] >= 9 THEN "Refund"
ELSEIF [Fun Score] >= 8 THEN "Really sick"
ELSEIF [Fun Score] >= 7 THEN "Sick"
ELSEIF [Fun Score] >= 6 THEN "Dizzy"
ELSEIF [Fun Score] >= 5 THEN "Feeling weird"
ELSEIF [Fun Score] >= 4 THEN "Pretty good"
ELSEIF [Fun Score] >= 3 THEN "Fun"
ELSEIF [Fun Score] >= 2 THEN "Great!"
ELSEIF [Fun Score] >= 1 THEN "AMAZING"
ELSEIF [Fun Score] < 1 THEN "LIFE CHANGING!"
ELSE NULL()
ENDIF

 

 

Hope that’s clear and helps you..

Labels
Top Solution Authors