ArcGIS 10.1 – Field Calculator If and Elseif Statement with Values

arcgis-10.1arcgis-desktopfield-calculatorpython-parser

Trying to figure out how to get this "Headwater" column to indicate "Yes" (or 1) if the value of "NextDown_Copy" is "" and "No" (or 0) if it has any other value (eg. 7100381010).

enter image description here

I attempted to try figuring out the Python code to do this using 1 and 0 coding (although I'd rather use Yes and No) (as illustrated below) but keep getting errors.
I consulted a few other posts (another one), but still wasn't able to find the problem.

enter image description here

Best Answer

Here's a simple expression with no need to define a function in the codeblock:

Headwater =

0 if !NextDown_Copy! else 1

This checks if each value of NextDown_Copy is truthy (i.e. not a null, 0, empty string), and returns a 0 if so, otherwise it returns a 1.

Related Question