I am using an expression to label features by concatenating two attributes in ArcMap. It works like this:
+" "+
Unfortunately when either attribute is Null the whole label is left blank. How do I change my expression so that if one attribute is Null, the other appears on its own?
Answer
Open Properties of the layer > Labels tab. Click the Expression button. Check the Advanced check box and then copy this code into the Expression window. You will have to use your fields names instead of fields I used.
def FindLabel([Type],[Name]):
if str([Type]) == "None" and str([NAME]) != "None":
return [Name]
elif str([Type]) != "None" and str([NAME]) == "None":
return [Type]
elif str([Type]) == "None" and str([NAME]) == "None":
return ""
else:
return str([Type]) + " " + str([Name])
No comments:
Post a Comment