0

How to use this formula in field calcultor in ArcMap. for example: A = Field1 B = Field2

  if A =<B
      C = B
  else:
      C = A
2
  • 1
    Does this answer your question? Using conditional statements in ArcGIS Field Calculator?
    – J.R
    Apr 10, 2020 at 13:30
  • 2
    Assuming neither value is None this is the same as the trivial Python expression max(!A!,!B!). The documentation for Field Calculator has multiple examples, and the UI tool will help you build the function. Please make an attempt, then Edit the question to reflect any problem you may encounter.
    – Vince
    Apr 10, 2020 at 13:31

1 Answer 1

2

@Vince is right and this could be solved using the max(!A!, !B!) expression. However, if you had a more complex situation you could use a custom function. In Arcmap you can write a function on the code block space and then call it where you usually write the expression.

Your function (code block) could look something like:

my_function(field1_value, field2_value):
    if field1_value <= field2_value:
        return field2_value
    else:
        return field1_value

Then you can call it using the following expression:

my_function(!A!, !B!)

Of course, you need to specify Python as the parser.

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