+ Reply to Thread
Results 1 to 11 of 11

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

  1. #1
    jamie finney
    Join Date
    Apr 2010
    Posts
    71
    Points
    2
    Answers Provided
    0


    0

    Default 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. #2
    Kent Marten
    Join Date
    Oct 2009
    Posts
    95
    Points
    17
    Answers Provided
    0


    0

    Lightbulb 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. #3
    Darsha Hardy
    Join Date
    Apr 2010
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default 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. #4
    Michael Blom
    Join Date
    May 2010
    Posts
    92
    Points
    3
    Answers Provided
    2


    0

    Default 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. #5
    tracy creighton
    Join Date
    Apr 2010
    Posts
    21
    Points
    1
    Answers Provided
    0


    0

    Default 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. #6
    Kent Marten
    Join Date
    Oct 2009
    Posts
    95
    Points
    17
    Answers Provided
    0


    1

    Thumbs up 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. #7
    tracy creighton
    Join Date
    Apr 2010
    Posts
    21
    Points
    1
    Answers Provided
    0


    0

    Default 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. #8
    jamie finney
    Join Date
    Apr 2010
    Posts
    71
    Points
    2
    Answers Provided
    0


    0

    Default 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. #9
    Arc GIS
    Join Date
    Sep 2012
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

    Default Re: list of field calculator functions and correct syntax's

    Quote Originally Posted by esrikmarten View Post
    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. #10
    Jessica Barnabei
    Join Date
    Sep 2012
    Posts
    22
    Points
    0
    Answers Provided
    1


    0

    Default 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. #11
    Chris Fox

    Join Date
    Oct 2009
    Posts
    523
    Points
    301
    Answers Provided
    36


    2

    Default Re: list of field calculator functions and correct syntax's

    Quote Originally Posted by jbarnabe View Post
    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!})
    Chris Fox
    Esri

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts