I have two fields in my model, the first is a spatial join return for the township, the second is a spatical join to a city. If there is not city, then the field is left blank. The column that has the city name, I wanted to use a if/then statment to fill in the blank columns with the township name, does anyone have any idea how I would write this or if this is even possible?
3 Answers
here is an example with the Python parser
code block
def fillBlank(city, township):
if (city == ""):
return township
else:
return city
expression (name of fields between ! !) :
fillBlank(!cities!, !township!)
Could you do it where you first spatial join to the city polygons, then do an attribute select to find where this column is blank, and then spatial join to the township polygons? Most Arc tools respect selections and only operate on selected records.
The vb script version is basically the same as the Python version posted by radouxju in terms of its logic. The code below also handles Null values in the Cities field.
If IsNull([Cities]) Then
Output = [Township]
ElseIf [Cities] <= " " Then
Output = [Township]
Else
Output = [Cities]
End If
Expression: Output