Start Free Trial

Alteryx Designer Desktop Discussions

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

invalid type in operator ==

gongyunqian622
7 - Meteor

I used

If [Name]=70 or [Name]=75 or [Name]=85
then
1/[Average Rate]
else
[Average Rate]
endif

It shows Invalid type in operator. How to fix it? (Data type is double)

5 REPLIES 5
Qiu
21 - Polaris
21 - Polaris

@gongyunqian622 

Do you have any Zero or null value in [Average Rate]?

gongyunqian622
7 - Meteor

yes, I have 0 for average value. How to fix it?

BrandonB
Alteryx
Alteryx

My guess is that your Name column is likely a string and therefore the values need to have quotes around them.

 

If [Name]=“70” or [Name]=“75” or [Name]=“85”

Qiu
21 - Polaris
21 - Polaris

@gongyunqian622 

If some like this

if [Average Rate] = 0 then 0 else 

If [Name]=70 or [Name]=75 or [Name]=85
then
1/[Average Rate]
else
[Average Rate]

endif

endif
Again the new column is numeric, we can only assign numbers.

 

RolandSchubert
16 - Nebula
16 - Nebula

Hi @gongyunqian622 ,

 

does it show something like tihs?

2020-11-11_07-45-18.png

This would throw an error like "invalid operator ..." 

I think you should double check data types, especially for the name field. If [Name] is a string field, you should replace

If [Name]=70 or [Name]=75 or [Name]=85 

by

If [Name]='70' or [Name]= '75' or [Name]= '85'  

If [Average Rate] isn't a numeric field, you could use ToNumber([Average Rate]) to convert it to numeric. 

 

Let me know if it works for you.

 

Best,

 

Roland

 

 

Labels
Top Solution Authors