I am using ArcGIS Desktop 10.5 here. I have a streets layer that has address ranges in the fields FromLeft, ToLeft, FromRight, and ToRight. I am trying to create a street index csv that has the low and high values for each street. I'm trying to calculate the min and max values across the 4 fields and calculate those into 2 new fields called MIN and MAX.

I used min( !FromLeft!, !FromRight!, !ToLeft!, !ToRight!) to get the minimum values.

The only thing is that some streets have 0 in one or more of these 4 fields. I would like to skip the value 0 from this calculation and only consider non-zero numbers.

Can this be done using the field calculator?

All my fields are LONGs.

enter image description here

1 Answer 1


Maybe there are easier ways, but here's one using Python.

  1. In the Field Calculator window, select the Python parser
  2. Check Show Codeblock
  3. The Pre-logic Script code defines a method that returns only values greater than 0.
def greater_than_0 (value):
    return value > 0
  1. The code for the MIN field is
min (filter (greater_than_0, [ !FromLeft!, !FromRight!, !ToLeft!, !ToRight! ]))

Note that this code will fail if all fields contain 0 values. If you have those, you may want to make a feature selection to exclude those records first

Here's a screenshot (Never mind my fieldnames, I used a scrap shapefile)

Field calculator

  • Thanks! Worked like a charm. Commented Jul 15, 2020 at 13:46
  • I can't get this code to work in ArcGIS Pro (python 9.3). Is there a difference? It seems to me the field calculator doesn't like this use of python's filter function? As soon as I add the 'filter', I get an error that says "No function was found with the name 'min' (even though the 'min' function works just fine when I don't employ 'filter'). Commented Feb 10, 2022 at 15:29

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.