I am trying to write a formula but I am getting an error 'The formula "Activity Completed" resulted in a string but the field is numeric Use ToNumber (...) if this is correct. (Expression #1)
.
The formula is as follows:
If [Activity Completed]=0 THEN 'NO'
ELSEIF [Activity Completed]=1 THEN 'YES'
ELSE
Null()
ENDIF
The data type is Int16. I tried to change the activity completed from 'Int16' to 'V_WString') at the select stage but then got a different message.
Any ideas how I can get the above formula to work?
Solved! Go to Solution.
By any chance are you trying to edit the current field, rather than add a new one? If so, the issue is that you're trying to replace numeric values with possible string outputs. In this case, I would make a new field and then use a Select afterwards to remove the original field and rename the latest. Or, add a select before the Formula tool to change [Activity Completed] to a string data type, and change the expression to:
If [Activity Completed]='0' THEN 'NO'
ELSEIF [Activity Completed]='1' THEN 'YES'
ELSE
Null()
ENDIF
You'll need the numbers in '' now, as they'll be in text form once you change the field type to a string with select.
I added a new column and this has worked. Thank you for your help.