I have created a new field to calculate the average of 3 other fields in a table where nulls are present. Using python as the parser(with no code block) I used this:

(!Slope_PCT! or 0 + !Flood_PCT! or 0 + !Wetland_PCT! or 0)/3

I get results but some of them are not correct.

  • How are you handling null values in your analysis? Are they actually 0, or do they really represent NoData? This could significantly change how you would want to run your analysis.
    – Aaron
    May 21 '14 at 13:25
  • 1
    In this case where there is nodata(null) we assume the value to be 0.
    – its30
    May 21 '14 at 13:28

Looks like I needed to add parens around each 'or' statement:

((!Slope_PCT! or 0) + (!Flood_PCT! or 0) + (!Wetland_PCT! or 0))/3

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.