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

IF Statement not working

geeklarokcmie
8 - Asteroid

I'm trying to use the below formula to execute results when [days old] column has the the respective values. I'm receiving incorrect values in the new column.

 

 

IF [Days_old] <='0' THEN 'Current'

ELSEIF [Days_old] <='30' THEN '1-30 days'

ELSEIF [Days_old] <='90' THEN '31-90 days'

ELSEIF [Days_old] >'91' THEN 'exceeds 90 days'

ELSEIF [Days_old] >'181' THEN 'exceeds 180 days'

ELSE "ERROR" ENDIF

 

Any help in rectifying the  error will be appreciated. Thanks

5 REPLIES 5
cjaneczko
13 - Pulsar

Check the field type. If its double, dont use the quotations. 

alexnajm
18 - Pollux
18 - Pollux

IS your [Days_old] column being stored as a number? If that's the case, I would remove the quotes around the numbers

 

IF [Days_old] <=0 THEN 'Current'

ELSEIF [Days_old] <=30 THEN '1-30 days'

ELSEIF [Days_old] <=90 THEN '31-90 days'

ELSEIF [Days_old] >91 THEN 'exceeds 90 days'

ELSEIF [Days_old] >181 THEN 'exceeds 180 days'

ELSE "ERROR" ENDIF

 

Otherwise what errors are you seeing?

Erin
11 - Bolide

Hi @geeklarokcmie,

 

I think for the greater than and less than symbols to work how you want them, then the Days_old field needs to be a number format. You also want to remove the single quotes around the numbers since it isn't a  text field. I switched up the formula a little in my test (attached) that might work better. 

IF [Days_old] <=0 THEN 'Current'

ELSEIF [Days_old] <=30 THEN '1-30 days'

ELSEIF [Days_old] <=90 THEN '31-90 days'

ELSEIF [Days_old] <=180 THEN 'exceeds 90 days'

ELSEIF [Days_old] >180 THEN 'exceeds 180 days'

ELSE "ERROR" ENDIF

RobertOdera
13 - Pulsar

Hi, @geeklarokcmie 

 

Consider the below. I hope you find it helpful - Cheers!

 

IF ToNumber([Days_old])  >180 THEN "exceeds 180 days"

ELSEIF ToNumber([Days_old])  >90 THEN "91-180 days"

ELSEIF ToNumber([Days_old])  >30 THEN "31-90 days"

ELSEIF ToNumber([Days_old])  >0   THEN "1-30 days"                         

ELSEIF ToNumber([Days_old]) <=0  THEN "Current"                   

ELSE "ERROR"

ENDIF

geeklarokcmie
8 - Asteroid

Thank you. Will certainly try that. 

Labels
Top Solution Authors