Solved! Go to Solution.
MaxVal = []
rows = arcpy.SearchCursor("Your Featureclass")
for row in rows:
MaxVal.append(row.Area1)
MaxVal.append(row.Area2)
MaxVal.append(row.Area3)
arcpy.CalculateField_management("Your Featureclass", "Area4", max(MaxVal), "VB", "")
If I could convert the <Null>s to zeros then I believe this the 'return max() function' might work.
def maxfld(fld1,fld2,fld3): try: lst = list() for k in (fld1,fld2,fld3): if k: lst.append(k) return max(lst) except: pass
import arcpy
rows = arcpy.SearchCursor("D:\Test\test.gdb\DataElements\FrequencyArea")
mylist = []
for row in rows:
vals = (row.Area1, row.Area2, row.Area3)
for val in vals:
if val not in (""," ",None):
mylist.append(val)
print max(mylist)
mylist = []IDLE 2.6.5 ==== No Subprocess ==== >>> 6.325 2.1 >>>
def maxNum(num1,num2,num3): maxNum = max([num for num in [num1,num2,num3] if num != '']) return maxNum
maxNum( int(!Area1!), int(!Area2!), int(!Area3!))
As I discovered by helping with another field calculator forum post, you can avoid having to convert null values by
passing the field to the function as integers, strings
>>> max(['103','1020']) '103' >>>