I am trying to calculate a field (NAT_RE_MI) by simply adding three other fields (FOR_FISH, MINING, FARM_EMP) together.

Some of the fields have a no data value of -98 or -99.

What code would I use to exclude those from the calculation in the Field Calculator for ArcGIS Pro?

1 Answer 1


Use an if to check the value of each field, and skip that value if it's one of your "no data" values. You can add other "no data" values to the no_data list to skip those as well.


skip_nodata(!FOR_FISH!, !MINING!, !FARM_EMP!)

Code Block:

def skip_nodata(val1, val2, val3):
    no_data = [-98, -99]
    x = 0
    if val1 not in no_data:
        x += val1
    if val2 not in no_data:
        x += val2
    if val3 not in no_data:
        x += val3
    return x

enter image description here

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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