Trying to create if then statement using the below:
IF [SECURITY_CLAS_CD] = 072 THEN "TIPS"
elseif [SECURITY_CLAS_CD] != "072" THEN " "
else endif
If it finds 072 output would be TIPS if not leave blank. Getting the below error
Parse Error at char(90): Unknown variable "endif" (Expression #1)
I've change it a few times but still can't figure it out. Thanks in advance
Solved! Go to Solution.
@darroyo01 you need to specify the value for your else condition. For example you could use: IF [SECURITY_CLAS_CD] = 072 THEN "TIPS"
elseif [SECURITY_CLAS_CD] != "072" THEN " "
else "" endif
Thanks for reply, now its it given the following error
Error: Formula (15): Parse Error at char(23): Invalid type in operator ==. (Expression #1)
IF [SECURITY_CLAS_CD] = 072 THEN "TIPS"
ELSEIF [SECURITY_CLAS_CD] != "072" THEN " "
ELSE""
ENDIF
@darroyo01
What is the data type of [SECURITY_CLAS_CD]?
One time you are using it as if it is a number and one time as if it is a string, that is the reason that you are getting the error.
If this field is a string then in both cases 072 needs to be in quote marks, if it is a number then it should not be in a quote marks.
Thanks I totally missed that. It ran now, but I didn't get the expected output.
IF [SECURITY_CLAS_CD] = "072" THEN "TIPS"
ELSEIF [SECURITY_CLAS_CD] != "072" THEN " "
ELSE""
ENDIF
I need output to show TIPS when it finds 072 and leave a blank where it doesn't. Thanks in advance
@darroyo01
It is due to the fact that your statement is incorrect.
No need the ELSEIF part as you have 2 conditions, or Tips or blank.
Just delete the ELSEIF row
IF [SECURITY_CLAS_CD] = "072" THEN "TIPS"
ELSE ""
ENDIF
The above says if it is 075 then Tips else blank
Thank you for you continued support. I almost there. Now getting the following error
Error: Formula (15): The formula "COMMENTARY" resulted in a string but the field is numeric. Use ToNumber(...) if this is correct. (Expression #1)
True | SECURITY_CLAS_CD | Double | 8 |
True | COMMENTARY | Double | 8 |
This is again relating to data type. As per Alteryx COMMENTAR has numeric data type, you need to ensure that it has a string data type, any of the string types. If you will add a Select tool before the formula tool you can see and change the data type of COMMENTAR
Thank you