Select to view content in your preferred language

Should be easy! Field Calculate Table using If/Then

2517
3
08-09-2012 01:22 PM
by Anonymous User
Not applicable
Original User: sfmeyer

Hello all.

I need to make a very simple field calculation, in modelbuilder.
[ATTACH=CONFIG]16818[/ATTACH]
For the values in the [DepthMin] field above, I want to replace any value > 2 with a 2.

The current value above (24.75) could be any number between 2 and 25 so doing a standard !replace! (24.75 , 2) will not work.

Any ideas? Thanks VERY much.
0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: sfmeyer

Nevermind. Used an alternative method.

Created a 2 step model first using the Make Table View tool with my selection expression " Value > 2"

Then performed the Calculate Field tool with "= 2"

I'm sure thereis a python logic that would plug right in but a fix is a fix. I'd still like to know the original answer if someone has it. Good day.
0 Kudos
MathewCoyle
Honored Contributor
def calc(DepthMin):
  if DepthMin > 2:
    return 2

calc( !DepthMin! )
0 Kudos
by Anonymous User
Not applicable
Original User: jscheirer

Did you mean:

def calc(DepthMin):
  if DepthMin > 2.0:
    return 2.0
  return DepthMin
0 Kudos