Alert: There is a planned Community maintenance outage October 16th from approximately 10 - 11 PM PST. During this time the Alteryx Community will be inaccessible. Thank you for your understanding!

Alteryx Designer Desktop Discussions

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

Unable to Fix IF Statement - Invalid Type in Operator

jjg21
6 - Meteoroid

I've been using the following statement:

 

IF [Days Outstanding]<31 THEN "0-30" ELSEIF [Days Outstanding]<61 THEN "31-60" ELSEIF [Days Outstanding]<91 THEN "61-90" ELSE "Over 90" ENDIF

 

Which keeps giving me an error at the "[Days Outstanding]<91" section saying that there is an invalid type in operator with the "<" underlined.

I cannot figure out what the error.

 

Appreciate the assistance.

 

Cheers

6 REPLIES 6
Qiu
21 - Polaris
21 - Polaris

@jjg21 
Please make sure the column [Days Outstanding] is of data type first.

and I have also ajusted the formula to set the low and high bounding.

Capture2A.PNG

apathetichell
19 - Altair

@Qiu-  if the datatype was wrong - shouldn't it throw off an error at the first compare? That the error apparently occurs at >91 makes me think that formula isn't exactly as transcribed above. Or perhaps the error is that it's a string set to 4 and "over 91" is too many characters so it's truncating.

 

I'm running it as a cut and paste directly in formula with a number going in and a string coming out and everything is fine.  I wouldn't write the formula that way - but it does work. So @jjg21  - try cutting and pasting it from what you posted here and see if fixes. Could be some stray character you're not seeing. @Qiu 's way of course works just as well. And personally, I'd do a switch command with some kind of floor division by 30.  But that's just personal preference.

2021-06-02 (5).png

jjg21
6 - Meteoroid

@QIU

Thank you! This makes everything work now. Yes - it looks as though the [Days Outstanding] was a Vstring (created through Formula) as opposed to IntXX which now works fine.

 

Thanks again

DawnDuong
13 - Pulsar
13 - Pulsar

Hi,

I am able to run the said formula (copy and paste as-is) without an issue on my local machine. Are you still encountering this issue?
Dawn

jjg21
6 - Meteoroid

Hi Dawn,

Error was fixed on my end upon changing item from Vstring to INT.

 

Thank you

Qiu
21 - Polaris
21 - Polaris

@jjg21 
if it helps, appreciate you would also mark the solutio as accept.😁

Labels