Early bird tickets for Inspire 2023 are now available! Discounted pricing closes on January 31st. Save your spot!

alteryx Community

# Alteryx Designer Discussions

SOLVED

## Need Help

5 - Atom

Hi All,

I am very new to the Alteryx, can anyone help me with below formula

if [Age] < "2" THEN "0-1"elseif(Age) >2 & <6 then "2-5" elseif (Age) >6 & <10 then "6-10"

4 REPLIES 4
22 - Nova

Hi @MMalkar

The formula would be converted to something like this

If [Age] is string

``````IF [Age] < "2" THEN "0-1"
ELSEIF [Age] >= "2" and [Age]<"6" THEN "2-5"
ELSEIF [Age] >= "6" and [Age]<"10" THEN "6-10"
ELSE Null() ENDIF``````

or If [Age] is number

``````IF [Age] < 2 THEN "0-1"
ELSEIF [Age] >= 2 and [Age]<6 THEN "2-5"
ELSEIF [Age] >= 6 and [Age]<10 THEN "6-10"
ELSE Null() ENDIF``````

Hope this helps 🙂

17 - Castor

Hi @MMalkar

Do you have sample data? Are you getting an error? At first glance you might need some updates to the syntax. Looks like you're trying to use numeric operators on strings which might not give you what you want (<"2"). Try the below, make sure your age field is numeric.

IF [Age] < 2 Then "0-1"

Elseif [Age] >=2 AND [Age] <6 Then "2-5"

elseif [Age] >=6 AND [Age] <10 then "6-10"

else null()

endif

5 - Atom

Alteryx

you need an ELSE statement any time you use a conditional.

IF [risk age]<2

THEN "0-1"

ELSE {put your alternate option here}

ENDIF

Also, pay attention to your data types in your incoming data. If [risk age] is a string, you will need to change it to a numeric format since you're using a mathematical function (less than)

You can see the data type by adding a browse tool, or clicking the "metadata" box in the results window.

Also note that your new column [Age bucket] has to be a string because of your quotes. You may want it to be numeric depending on what you're doing with it later.

Labels