2

I want to run a field calculation on a string field named [territory] that first looks at a string field [majr_src] to see if there is a value other than "NONE", if so [territory] = [majr_src]. If not, it looks at field [top_pct] to see if it is >30, if so [territory] is assigned the value of another string field called [Top_src]. Finally, if neither of these conditions are met it assigns [Territory] the value from a final string field called [Close_src]

I have: Pre-Logic Script Code:

def selectter(n):
 if [Majr_src] != "NONE":
  n = "[Majr_src]"
 else:
  if [Top_pct] > 30:
   n = "[Top_src]"
  else:
   n = "[Close_src]"

and

Territory =
 selectter([Territory])

I am using ArcMap 10.1

1 Answer 1

2

Make sure that you have set your parser to Python (as suggested by @Arabella) and then try something more like this untested code:

Pre-Logic Script Code:

def selectter(Majr_src,Top_pct,Top_src,Close_src):
 if Majr_src != "NONE":
  return Majr_src
 else:
  if Top_pct > 30:
   return Top_src
  else:
   return Close_src

and Territory =

selectter(!Majr_src!,!Top_pct!,!Top_src!,!Close_src!)

A key to understanding how code blocks work in the Field Calculator is learning how to use Python functions.

0

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.