Need Help
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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"
Solved! Go to Solution.
- Labels:
- Best Practices
- Error Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
