Alteryx Designer Desktop Discussions

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

Error The formula resulted in a string but the field is numeric Use To Number

dlemoine
6 - Meteoroid

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?

2 REPLIES 2
DataNath
17 - Castor

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.

dlemoine
6 - Meteoroid

 I added a new column and this has worked. Thank you for your help.

Labels