We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

IF ELSE Statement for Age bucketing

ccarr5
5 - Atom

I am currently trying to complete a simple age bucketing equation but am receiving a Malformed IF statement error and I am not too sure where I am off. Below is the current equation that I have written out;

 

IF [DaysOutstanding]=1 then "S1"
else IF [DaysOutstanding]<=7 then "2-7"
else if [DaysOutstanding]<=15 then "8-15"
else if [DaysOutstanding]<=30 then "16-30"
else if [DaysOutstanding]<=60 then "31-60"
else if [DaysOutstanding]<=90 then "61-90"
else if [DaysOutstanding]<=180 then "91-180"
else ">180" ENDIF

 

ccarr5_0-1650048277139.png

 

 

5 REPLIES 5
patrick_digan
17 - Castor
17 - Castor

Hi @ccarr5 , try deleting the space between the else and if (so they become elseif)

patrick_digan
17 - Castor
17 - Castor

You'll also want to change your data type as well to string/vstring.

ccarr5
5 - Atom

Thank you Patrick, an oversight on my part. Unfortunately it resulted in an "Invalid Type in operator <=" error. Any thoughts on what I might be missing here?

ccarr5_0-1650049266960.png

 

CharlieS
17 - Castor
17 - Castor

Perhaps your [DaysOutstanding] field is not configured as a numeric field? If that's the case, you can add the "ToNumber(" function in your expression so the numeric test ("<=") can take place.

IF ToNumber([DaysOutstanding])=1 then "S1"

elseif ToNumber([DaysOutstanding])<=7 then "2-7"
elseif ToNumber([DaysOutstanding])<=15 then "8-15"
elseif ToNumber([DaysOutstanding])<=30 then "16-30"
elseif ToNumber([DaysOutstanding])<=60 then "31-60"
elseif ToNumber([DaysOutstanding])<=90 then "61-90"
elseif ToNumber([DaysOutstanding])<=180 then "91-180"
else ">180" ENDIF

MarqueeCrew
20 - Arcturus
20 - Arcturus

You might also want to play with the TILE tool with manual tiles. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

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