Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Issue with IF formula

bakaidora
8 - Asteroid

Hello Together,

 

I would like to create an IF formula to categorize the "days" information what I got in the "Days until due date" column.

 

Do you have any idea what can be the issue? The error message show me "Invalid type in operator <."

 

Thansk in advance,

 

IF [Days until due date]>60
THEN "Overdue > 60 days"

ELSEIF [Days until due date]>31 and [Days until due date]<=60
THEN "Overdue 31-60 days"

ELSEIF [Days until due date]>21 and [Days until due date]<=30
THEN "Overdue 21-30 days"

ELSEIF [Days until due date]>11 and [Days until due date]<=20
THEN "Overdue 11-20 days"

ELSEIF [Days until due date]>=0 and [Days until due date]<=10
THEN "Overdue < 10 days"

ELSEIF [Days until due date]<0 and [Days until due date]>=-5
THEN "Due in 5 days"

ELSEIF [Days until due date]<-5 and [Days until due date]>=-10
THEN "Due in 10 days"

ELSEIF [Days until due date]<-10 and [Days until due date]>=-20
THEN "Due in 20 days"

ELSEIF [Days until due date]<-20
THEN "Due in 30 days"

ELSE ""

ENDIF

7 REPLIES 7
Jean-Balteryx
16 - Nebula
16 - Nebula

Hi @bakaidora ,

 

it looks like your field [Days until due date] isn't numeric type. Is it the case ?

atcodedog05
22 - Nova
22 - Nova

Hi @bakaidora 

 

As @Jean-Balteryx said it could be possible [Days until due date] isn't numeric. 

 

You can convert it to numeric by

1. Using select tool before to convert to numeric (int/double)

or

2. Use tonumber([Days until due date]) instead of [Days until due date].

 

Hope this helps : )

Jean-Balteryx
16 - Nebula
16 - Nebula

Also you should replace "<" by "<=" for values 31,21 and 11 as they are not in any range being excluded.

Jean-Balteryx
16 - Nebula
16 - Nebula

I'd suggest the first solution offered by @atcodedog05 as it will get you better performances because you won't change type each time you check a condition.

atcodedog05
22 - Nova
22 - Nova

@Jean-Balteryx wrote:

Also you should replace "<" by "<=" for values 31,21 and 11 as they are not in any range being excluded.


Good catch on this @Jean-Balteryx 🙂👍

bakaidora
8 - Asteroid

Thanks for the help, it was the issue what you mentioned. 🙂 I used the Select tool for type change.

I changed the "<" to "<=" in case of 31,21,11, as well. 🙂

Thanks again and have a nice day.

Jean-Balteryx
16 - Nebula
16 - Nebula

You are welcome ! Have a great day ! 🙂

Labels
Top Solution Authors