# Thread: list of field calculator functions and correct syntax's

1. ## list of field calculator functions and correct syntax's

does any one know of any reference guides to show all available field calculator functions and the correct sytax for each?

emailed tech support and they showed me this: http://resources.arcgis.com/content/...leShow&d=29627

though can't seem to find what i'm looking for.

one problem i was having was working out the maximum value from two colums

ID | DEPTH_1 | DEPTH_2 | MAX_DEPTH
...
...
...

in the end i ended up converting my shp to tab and doing it in MapInfo updating the "MAX_DEPTH" field using "maximum(DEPTH_1,DEPTH_2)"

i am positive that this function exists in Arc i just don't seem to be able to find it, i've tried a fair few combinations of "max" "maximum" "()" "[]" and can't seem to find a statement that works in arc any ideas?

2. ## Re: list of field calculator functions and correct syntax's

Hi Jamie,

The Field Calculator supports both VBScript and Python in ArcGIS 10. For a complete list of functions for these supported scripting languages you can visit these websites:

http://msdn.microsoft.com/en-us/libr...ek(VS.85).aspx

http://docs.python.org/library/string.html
http://docs.python.org/library/numeric.html
http://docs.python.org/library/datetime.html

VBA support is now deprecated from the Field Calculator in ArcGIS 10.

Thanks,
Kent M.
esri

3. ## Re: list of field calculator functions and correct syntax's

if it's just comparing the two values on each row you could use an IF statement

or this mathematical formula looks interesting

4. ## Re: list of field calculator functions and correct syntax's

Hi there:

I'm trying to do this also.
Kent M, as of June 2010, i dont think many (any) of us are using ArcGIS 10.

Does anyone actually have a VBA formula to calculate max/min values across multiple fields in the Field Calculator?

Thanks,
Mike

5. ## Re: list of field calculator functions and correct syntax's

Hi Kent,
I am still looking for the answer to Jamie's question. How can I do this in Arc10? If anybody has the actual formula, or could walk me through the process of implementing the Python functions linked about, it would be greatly appreciated.
Thanks
Tracy

6. ## Re: list of field calculator functions and correct syntax's

You can use Python to get the Max value of multiple fields. Make sure to set the Parser type on the Field Calculator to Python.

Option #1 Using a simple expression:
Code:
`max([!field1!, !field2!, !field3!])`
Option #2 Using a codeblock:
Code:
```def calcmax(a,b,c):
array=[a,b,c]
theMax = max(array)
return theMax```
MaxField =
Code:
`calcmax([!field1!, !field2!, !field3!])`

7. ## Re: list of field calculator functions and correct syntax's

BRILLIANT! Thank you Kent. It has taken me way to long to get to this point. Perhaps some of these examples could also be listed in the help section of the field calculator, or in the help files somewhere. Coming into v10 with no Python knowledge suddenly makes simple things very frustrating...
Anyhow, I won't get started with that. I appreciate your help very much.

8. ## Re: list of field calculator functions and correct syntax's

esrikmarten thats great thanks for posting nice to know this function does exist and now i can do it in arc

9. ## Re: list of field calculator functions and correct syntax's

Originally Posted by esrikmarten
You can use Python to get the Max value of multiple fields. Make sure to set the Parser type on the Field Calculator to Python.

Option #1 Using a simple expression:
Code:
`max([!field1!, !field2!, !field3!])`
Option #2 Using a codeblock:
Code:
```def calcmax(a,b,c):
array=[a,b,c]
theMax = max(array)
return theMax```
MaxField =
Code:
`calcmax([!field1!, !field2!, !field3!])`
Does anybody know if it´s possible to choose more than one field at the same time from the field list? It`s very time-intensive, if there are more than - let`s say - 10 fields...

Greets
Björn

10. ## Re: list of field calculator functions and correct syntax's

This worked great, but what I actually would like to have is the Field Name of the highest value populate the new field. For example, I have 3 columns, Age25_44, Age45_64, and Age65over. I would like the new field I added to calculate which field name contains the highest value. So the output would be text, not numbers. I know it is possible in Excel. I am hoping it is possible in ArcGIS without having to export to Excel and then re-import.

Thanks,
Jessica

11. ## Re: list of field calculator functions and correct syntax's

Originally Posted by jbarnabe
This worked great, but what I actually would like to have is the Field Name of the highest value populate the new field. For example, I have 3 columns, Age25_44, Age45_64, and Age65over. I would like the new field I added to calculate which field name contains the highest value. So the output would be text, not numbers. I know it is possible in Excel. I am hoping it is possible in ArcGIS without having to export to Excel and then re-import.

Thanks,
Jessica
Try this:

Code:
Code:
```import operator
def GetMaxFieldName(fields):
return max(fields.iteritems(), key=operator.itemgetter(1))[0]```
MaxField =
Code:
`GetMaxFieldName({"Age25_44": !Age25_44!,"Age45_64": !Age45_64!,"Age65over": !Age65over!})`