3

I am trying to pass the Null values in label expression in advance python section. I have this code and it's not working. Note that all my values in [TX_SECT] and [ABSTRACT] are numbers.

def FindLabel ( [TX_SECT], [ABSTRACT] ):
    if [TX_SECT] == "None" and [ABSTRACT] != "None":
        return [ABSTRACT]
    elif  [TX_SECT] != "None" and [ABSTRACT] ==  "None":
        return [ABSTRACT]
    elif [TX_SECT] == "None" and  [ABSTRACT] == "None":
        return ""
    else:
        return [TX_SECT] + '\n' + [ABSTRACT]
  • Should the second part of the conditional return [TX_SECT] instead of [ABSTRACT]? – Erica Sep 19 '14 at 18:44
5

as your values [abstract] and [TX_sect] are number, you should return them as string using str([abstract])

Secondly, "None" will be a string, not the null value. You must test it with

[field] is None

Finally, your condition should be written in parenthesis :

if ([TX_SECT] is None and not([ABSTRACT] is None)):

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.