AnsweredAssumed Answered

Python IF/THEN within Field Calculator

Question asked by Cep86 on Mar 23, 2015
Latest reply on Mar 23, 2015 by rfairhur24

Hello,

 

I am trying to create a python IF/THEN statement within a model that runs the field calculator tool.  Essentially I want it to check to make sure if a cell has data entered (IS NOT NULL), and if so, calculate a concatenation of 4 other fields. 

 

Sample of what I want:

 

IF field1 <> NULL

    THEN field2 = concatenation expression

ELSE field1 still = NULL

 

My python skills are very rudimentary, and I have only tested off of what I've found through googling python IF/THEN statements.  I don't fully understand how to take their samples and make them work with what I need to accomplish.  One of the samples that I've tried to mimic is pasted below:

 

Expression:
Reclass(!WELL_YIELD!)

Expression Type:
PYTHON_9.3

Code Block:
def Reclass(WellYield):
  if (WellYield >= 0 and WellYield <= 10):
  return 1
  elif (WellYield > 10 and WellYield <= 20):
  return 2
  elif (WellYield > 20 and WellYield <= 30):
  return 3
  elif (WellYield > 30):
  return 4

Outcomes