How to select the maximum value in a row

226
3
06-02-2019 11:48 PM
KK2
by
New Contributor III

I would like to know if there is a way to find a maximum value in an attribute table in a row.

I have few columns representing different valuables of an object and I would like to know which variable has the highest value across all of them? Is there a ready to use function to do this? Thanks in advance for your answers.

0 Kudos
3 Replies
NeilAyres
MVP Frequent Contributor

I don't know of an existing tool to do this.

You may want to try a little python, like this (btw completely untested)

import arcpy

pathtodata = r"c:/some/path/to/data/db.fgb/mydata"

flds = ["field1", "field2", "field3"]

with arcpy.da.SearchCursor(pathtodata, flds) as Cur:
for row in Cur:
minval = -9999999
minfld = None
for v in range(len(flds)):
if row[v] > minval:
minval = row[v]
minfld = flds[v]
print "Fld {} min {}".format(minfld, minval)
NeilAyres
MVP Frequent Contributor

Those variables

minval, minfld

should of course be named

maxval, maxfld

for clarity.

KK2
by
New Contributor III

Thank you for your answer, but If I understand you correctly this script will find the minimum values only (at least such results I achieved by running this script). I do not have the minimum values and I am asking whether it is possible to calculate the values of each angle of a polygon in Arc Map, and then to find those that have very small values.

0 Kudos