ArcMap – Writing Label Expressions with If-Then Statements for Efficient Labeling

arcgis-desktoparcmapif elselabeling

I am having problems with label expression in ArcMap 10.2.1.

I want to show two labels per polygon, but only when there are two labels to show.
Every polygon has at least one label (Veg_Dominant), but some polygons also have a second (Veg_codominant). I want polygons with only one label to show this one label, and polygons with two labels to show both with a '+' sign in between.

This is how I entered it in the label expression:

enter image description here

This is how it looks in the map:

enter image description here

is there a way to only show the '+' sign when there is more than one label to show?

Best Answer

In the Label Expression, switch to "advanced", select VBScript as Parser, and paste this code:

Function FindLabel ( [veg_dominant] , [veg_codominant]  )
if [veg_codominant] <> " " then
  FindLabel = [veg_dominant] + "+" + [veg_codominant]
else
 FindLabel = [veg_dominant]
end if
End Function

This expression means: if veg_codominant has values, then the label will be field1+field2, otherwise if the field is empty, use only field1 as the label

Related Question