Skip to main content
edited tags; edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to Field Calculate Calculating only the values that aren'tare not null? in field using ArcGIS Pro

naming; removed appreciation
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

I'm using ArcProArcGIS Pro, the field calculator. I want to populate a hydrant layer with hydrant inspection data. I have two fields from a joined table: field 1 and field 2. I want to populate field 1 with the values from field 2, but only if the values ARE NOT Null. Basically I want to preserve the values in field 1 if the corresponding value in field 2 is Null. I've been trying slight variations of the python code below. But it just populates field 1 with all of field 2 whether there are nulls or not.

I'm a beginner when it comes to python, so any help is much appreciated!Python.

Codeblock:

def reclass(f1,f2):
        if f2 is not None:
            return f2
        else:
            pass

Expression:

reclass(!field1!,!field2!)

I'm using ArcPro, the field calculator. I want to populate a hydrant layer with hydrant inspection data. I have two fields from a joined table: field 1 and field 2. I want to populate field 1 with the values from field 2, but only if the values ARE NOT Null. Basically I want to preserve the values in field 1 if the corresponding value in field 2 is Null. I've been trying slight variations of the python code below. But it just populates field 1 with all of field 2 whether there are nulls or not.

I'm a beginner when it comes to python, so any help is much appreciated!

Codeblock:

def reclass(f1,f2):
        if f2 is not None:
            return f2
        else:
            pass

Expression:

reclass(!field1!,!field2!)

I'm using ArcGIS Pro, the field calculator. I want to populate a hydrant layer with hydrant inspection data. I have two fields from a joined table: field 1 and field 2. I want to populate field 1 with the values from field 2, but only if the values ARE NOT Null. Basically I want to preserve the values in field 1 if the corresponding value in field 2 is Null. I've been trying slight variations of the python code below. But it just populates field 1 with all of field 2 whether there are nulls or not.

I'm a beginner when it comes to Python.

Codeblock:

def reclass(f1,f2):
        if f2 is not None:
            return f2
        else:
            pass

Expression:

reclass(!field1!,!field2!)
Source Link
Katie B.
  • 807
  • 1
  • 7
  • 18

How to Field Calculate only the values that aren't null?

I'm using ArcPro, the field calculator. I want to populate a hydrant layer with hydrant inspection data. I have two fields from a joined table: field 1 and field 2. I want to populate field 1 with the values from field 2, but only if the values ARE NOT Null. Basically I want to preserve the values in field 1 if the corresponding value in field 2 is Null. I've been trying slight variations of the python code below. But it just populates field 1 with all of field 2 whether there are nulls or not.

I'm a beginner when it comes to python, so any help is much appreciated!

Codeblock:

def reclass(f1,f2):
        if f2 is not None:
            return f2
        else:
            pass

Expression:

reclass(!field1!,!field2!)