I'm working from a geodatabase in ArcMap 10.5, and using Model Builder.

I currently have a field with values that range from 0 to 30 and I want to convert that to a 0-10 scale. The idea was to use a formula like:


Which, after some minor research, I assumed would be something like this in Field Calculator (using...):


But it doesn't work. The calculator does not return any error, it just doesn't give the exepected results. I tried adding [] to the max function, adding some extra fields so i has something else to search on, etc, but I always get one of these results:

  • All with value = 1 and some NULLs (which is odd 'casue there are no initial NULL values)
  • All with value = 10 and some NULLs (same as above in this case)

Any of these makes sense taking the formula in mind, but there is also no error message, so I assume there is some piece I am missing to make the calculation work correctly.

How can I (if it's even possible) get the max value in a field to calculate this formula?

Doesn't matter if it's VB Script or Python (currently using the latter) or even if it's some workaround, as long as it works.

  • Have you tried forcing the input to float type? I often encountered similar nonsensical results without errors in the raster calculator when dividing values. float(index)/float(max(index)) This is due to the fact that in the old python 2.7, if I am not wrong, the ratio operator returns the same type of the input. Commented Mar 18, 2020 at 13:01
  • @AndreaMassetti i have not, but will do when i can since now i do not have the data available. Thanks for the suggestion, will let you know how it worked.
    – adriasf
    Commented Mar 25, 2020 at 20:43

2 Answers 2


Just right click on the field header of the INDEX field and choose Statistics, you will be presented with some basic but useful stats, including maximum value. Note this will honour any selection on your table.

The reason why your approach has not worked is because to answer the question what is the maximum value would require you to traverse the table searching for that first but you have embedded the max() function into an operation that steps through the table one row at a time. Chicken and egg scenario! So you either use the summary tool to find the maximum value and store it away or use the approach I have suggested above.

  • That was my initial solution, but it works only for the first time since (I forgot to mention in the question) I'm working with a Model Builder. I was able to check the max value and calculate the new range manually, but this will be transported to an automated process and I won't have the chance to check the max before it runs Calculate Field. Unless I add a new field just to calculate the new range which, initially, I'm not inclined to unless it is mandatory.
    – adriasf
    Commented Dec 3, 2019 at 7:26
  • My current idea is to somehow get the max value from the field into a new field where every row will be equal to max value, and then be able to calculate the new range using this field rather than an embedded max() function. The problem is I don't even seem to be able to extrapolate the max value alone to a new field.
    – adriasf
    Commented Dec 3, 2019 at 7:41
  • Not mentioning you are doing all this in modelbuilder is a major oversight! Use the summary tool to create a table with one row which is the MAX of the field. Then use the model only tool Get Field Value to grab that value and then you can use that using inline variable substitution. Suggest you edit your question and tag appropriately for others.
    – Hornbydd
    Commented Dec 3, 2019 at 11:33
  • I've been able to get the max value using the method you suggested, but how can I "connect" it to the Calculate Field process? Right now I've used the manual Connect tool and the Calculate Field gets the value, although I'm not sure, once embedded in the expression, this value will change when executing the model again.
    – adriasf
    Commented Dec 3, 2019 at 13:39
  • Have a look at the help file! Key words "Get Field Value" and inline substitution.
    – Hornbydd
    Commented Dec 3, 2019 at 21:06

If you fancy python (it can be run in the python console or standalone):

import arcpy

## input file
file = r'input_shapefile_or_other_file.shp'

field_to_max = 'from_node' ### field with values
field_to_update = 'grid_code' ### create new field (before), which will be updated

values = []
with arcpy.da.SearchCursor(file, [field_to_max]) as cursor, arcpy.da.UpdateCursor(file, [field_to_max, field_to_update]) as upd_cursor:
    for row in cursor:
    max = max(values) ### get max value
    for row in upd_cursor:
        value = (float(row[0]) / float(max)) * 10

        row[1] = int(value) ### calculate value
        upd_cursor.updateRow(row) ### set value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.