Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Formula error

JingYih_Herbalife
8 - Asteroid

Hi, 

 

Would like to know what is wrong with the formula below. I got the error "Error: Formula (51): Parse Error at char(81): Invalid type in operator <. (Expression #1)"

 

IIF([Hours Closed]<24, "<24", IIF([Hours Closed]<48, "24-48", IIF([Hours Closed]<72,"49-72",">72")))

 

Thanks in advance. 

4 REPLIES 4
flying008
15 - Aurora

Hi,@JingYih_Herbalife 

 

Try this:

IIF(ToNumber([Hours Closed]) < 24, "<24", IIF(ToNumber([Hours Closed]) < 48, "24-48", IIF(ToNumber([Hours Closed]) < 72,"49-72",">72")))
Qiu
21 - Polaris
21 - Polaris

@JingYih_Herbalife 
Just try to be more careful about the value of 48 and 72 😁

0226-JingYih_Herbalife.png

 

DawnDuong
13 - Pulsar
13 - Pulsar

hi @JingYih_Herbalife 

From pure "Excel" syntax, your formula is fine (but the logic is not).

The error message "Error: Formula (51): Parse Error at char(81): Invalid type in operator <. (Expression #1)" indicates that this is a type error.

Alteryx is a type-strong language, so you need to make sure that the data type is appropriate. In this case, it looks like the field "Hours Closed" is not numeric. Please check what type you have assigned it - or, alternatively you can insert a Select tool, to change the field "Hours Closed" to one of the acceptable numeric types (anything between Byte and Double if you click on the drop down will work).

 

Syntax aside, please also have a 2nd look at the logic. With the current formula, if Hours Closed = 48, then the output will give "49-72". is this your intended outcome?

 

Cheers,

Dawn.

aatalai
15 - Aurora

@JingYih_Herbalife  you can try this too

 

If Tonumber([hours closed]) < 24 then "<24"

 

elseif  Tonumber([hours closed]) >=24  and Tonumber([hours closed]) <= 48 then "24-48"

 

elseif  Tonumber([hours closed]) >=49  and Tonumber([hours closed]) <= 72 then "49-72"

 

else ">72" endif

Labels
Top Solution Authors