ArcGIS Desktop – Using File Geodatabase with Null Values in Field Calculator in ArcGIS 10.0

arcgis-10.0arcgis-desktopfield-calculatorfile-geodatabasepython

I want to use the field calculator to get the sum of a couple of columns. The problem is that some of them has Null Values. I am not able to find a solution.
I tried this Python functions:

stack( !basic.Blue_Thickness!, !basic.Green_Thickness!, !basic.Red_Thickness!, !basic.F1_Thickness! )

Version 1:

def stack(*args):
  myList = list(args)
  myList = [item for item in myList if (item is not None)]
  return sum(myList)

Version 2:

def stack(*args):
    return sum(filter(None, args))

Version 3:

def stack(*args):
  myList = list(args)    
  for item in myList:
    if item is None: 
      myList.remove(item)
  return sum(myList)

The result of all this functions is that I get always NULL back, only if there is a row with no NULL then I get a result.

Background: I have a File Geodatabase with one main table and some tables which joins this table. The calulation takes place only in the main table (source columns and write column). I am using ArcGIS 10.0.
The Source of these functions is this discussion:
Calculating field in which null values may be present?

Best Answer

I just ran the test below in the Field Calculator and it seemed to work.

def stack(item1,item2,item3):
  itemList = [item1,item2,item3]
  myList = [item for item in itemList if (item != None)]
  return sum(myList)

This was the Field Calculator settings I used:

enter image description here

and this is the test table with the result:

enter image description here

I think the only thing that I am not doing at the moment is joining through to another table but before I test that (I am using ArcGIS 10.1 SP1) perhaps you can confirm that this simple test is working for you. It's not as Pythonic but seems to work.