The If Then statement is suppose to output the Length of Assignment in days. Any value between 0 and 365 days is to output 1 into the 1 or 2 column. Otherwise all other values are suppose to indicate 2 in the 1 or 2 column.
There are values in Length of assignment that are over 1000 and indicating 1 when it should be 2.
I need some help figuring out why the values are returning the wrong output.
@awhitehead012
You are assigning the field "Length of Assignment" as String, which should be numeric such as "Int16".
One thing I always add on to fields of numeric comparison is the "ToNumber()" expression. So riding on @Qiu 's work, I can state:
IF ToNumber([Length of Assignment]) >= 0
AND ToNumber([Length of Assignment]) <= 365
THEN 1
ELSE 2
ENDIF
So in this case, even if I forget or let's say the field changes data types dynamically, the content is still numeric in nature. So it is unlikely to go into error. The other upside is that if something changes, let's say the data type shifts from numeric to string by force, then you will get warnings instead of an error. Easier to troubleshoot as well.
@awhitehead012
Can you check my workflow?
We need to make sure that "[Length of Assignment]" is a numeric field, which can be achieved by assigning it to Int32 in the formula too.
Now since we are comparing numeric values, remove the "" around 0 and 365. Adding quote to a number will make it string type value.
To follow up- I also removed the "" around THEN, ELSE (1,2) -its not shown in screenshot
@awhitehead012
Like I said, Put quotation around number will make it to be String so you can not compare.
@awhitehead012
And also ToNumber function is not used correctly.
Can you just download and check my sample workflow?
It should be like this
ToNumber([Length of Assignment]) >= 0
Hello Qiu,
I appreciate your willingness to support and provide the exact workflow but I am also hoping to learn myself instead of use what someone built for me. I checked your workflow, I copied the same formula into mine and its not working. I would like to understand why its not working. I have removed all "" and both data types reflect INT32.