I am trying to calculate a field based on the values of 3 other fields. 2 are text and 1 is defined as double. When I run the following code only using the 2 text fields everything works as expected:
myCalc(!ASSIGNED!,!DEFAULTED!)
def myCalc(ASSIGNED,DEFAULTED,):
if (ASSIGNED=='YES')and(DEFAULTED=='NO'):
return 'NO'
elif (ASSIGNED=='YES')and(DEFAULTED=='YES'):
return 'YES'
elif (ASSIGNED=='NO')and(DEFAULTED=='YES'):
return 'YES'
elif (ASSIGNED=='NO')and(DEFAULTED=='NO'):
return 'YES'
else:
return 'INCONCLUSIVE'
However when I try to assess against the 3rd field most of the statements get ignored and only a few are implemented as expected. No errors or warnings are generated. This results in most of the results coming in as Inconclusive as generated by the final statement. Given the data I am using no result should come in as inconclusive since no value is blank or null. The logic for assessing the 3rd field is as follows:
def myCalc(ASSIGNED,DEFAULTED,DISTANCE,):
if (ASSIGNED=='YES')and(DEFAULTED=='NO'):
return 'NO'
elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE<21):
return 'YES'
elif (ASSIGNED=='YES')and(DEFAULTED=='YES')and(DISTANCE>=21):
return 'NO'
elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE<21):
return 'YES'
elif (ASSIGNED=='NO')and(DEFAULTED=='YES')and(DISTANCE>=21):
return 'NO'
elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE<21):
return 'YES'
elif (ASSIGNED=='NO')and(DEFAULTED=='NO')and(DISTANCE>=21):
return 'NO'
else:
return 'INCONCLUSIVE'
If the value for distance is placed in single quotes I get error 000539. Any help is greatly appreciated.