HOW TO

Label a feature with multiple records in a joined or related table in ArcGIS Pro

Last Published: April 25, 2020

Summary

A feature labelled with descriptive text is helpful when there are multiple features available in a close distance. The label displays the values of certain fields from the attribute table. Sometimes, features of one table are associated with features of another table through joins or relates.

Procedure

To label a feature with multiple records, the feature must be in a permanent one-to-many join. The following steps describe how to do so:

  1. Use the Make Query Table tool to make a permanent join between the selected records. Refer to ArcGIS Pro: Make Query Table for more information on the tool. This tool creates a new feature layer.
  2. Open the newly created feature attribute table, and add a new Text type field. Refer to ArcGIS Pro: Add data to an existing table for more information.
  3. Click Calculate The image of the Calculate icon in the attribute table to open the Calculate Field console. Select the newly created field from the Field Name drop-down list, and select Python 3 in the Expression Type drop-down list.
  4. Type the following script in the expression text box:
isDuplicate(!<Selected_Field_ To_Label>!)
  1. Insert the following script in the Code Block text box to identify repeating values, and replace them with Null and 0.
uniqueList=[] 
def isDuplicate(inValue): 
 if inValue in uniqueList: 
   return 0 
 else: 
   uniqueList.append(inValue)
Click the Verify The image of the Verify button button to ensure the expression is valid, and click Run.
  1. Clear the script in the Code Block text box, and insert the following script in the expression text box to replace all Null and O values with a blank value.
'Name:!<Selected_Field_ To_Label>!' if !<New_Field_Name>! is None else " "
The image of the Expression text box
Click Run.
  1. Right-click the feature layer and select Labelling Properties to open the Label Class console. Select the Python parser from the Language drop-down selection, and check the Advanced check box.
  2. Type the following script in the Expression text box:
def FindLabel ([New_Field_Name],[Field_Name2],[Field_Name3]):
  myText = [New_Field_Name]
  if [Field_Name3] == "<Desired_Text>":
     myText = myText + "<CLR blue = '255'>"+[Field_Name2]+"</CLR>"+ "\n"
  else:
     myText = myText + "<CLR red = '255'>"+[Field_Name2]+"</CLR>"+ "\n"

  return myText
Click Apply.

Article ID:000021133

Software:
  • ArcGIS Pro

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic