I need to sum values of 2 columns in field calculator and populate a new column with the result, one of the values always in Null. I already had found a useful answer In here, but it doesn't help with the last couple of columns, that contain a date in DD.MM.YYYY (string) format- geoprocessing report shows successful operation, but the new column stays empty. Is there a small tweak i could use for the code, to make it work?
def stack(Y, Y_1):
itemList = [Y, Y_1]
myList = [Y for Y in itemList if (Y != None)]
return sum(myList)
Field value= stack( !Y!, !Y_1!)
Best Answer
Based on your comments, it sounds like
sum
is not quite the right name for the field. You want to coalesce two fields.This post on StackOverflow can give you more background on coalesce.