[GIS] Using Python if/then/else to return value from either of two fields based on value of third using ArcGIS Field Calculator

arcgis-10.0arcgis-desktopfield-calculatorpython-parser

I'm trying to avoid manually inputting Begin and End engineering station values already inputted into a seperate field.

I'm dealing with(4) fields:

  • Begin_Sta
  • End_Sta
  • Beg_End and
  • Station.

The Begin_Sta and End_Sta fields have engineering stations. The Beg_End field has either "BEGIN" or "END" inputted. The Station field is the one I want to populate using python in the field calculator.

If Beg_End has "BEGIN" then the engineering station value in the Begin_Sta field is returned into the Station field, else the End_Sta value is used to populate the Station field.

Is this possible using python in the Field Calculator?

Best Answer

Yes it is possible, right click your 'Station' field and select Field Calculator. Select python as the parser and check the Show Codeblock box, see screen capture below for code snippet:

enter image description here