HOW TO

Add leading zeroes to labels in ArcGIS Pro

Last Published: January 10, 2024

Summary

In ArcGIS Pro, sometimes it is necessary to display numeric field values with leading zeroes when displaying as labels for better data management. The leading zeroes can be added to the numeric field values in the attribute table in ArcGIS Pro. However, this article provides the workflow to add leading zeros when displaying labels using a Python or Arcade expression while retaining the original data in the attribute table in ArcGIS Pro.

Labels before adding leading zeroes.png

Procedure

  1. Open the ArcGIS Pro project, add the layer, and create the label expression. For instructions, refer to Steps 1 through 4 in ArcGIS Pro: Write a label expression, and select Arcade or Python from the Language drop-down list.
Note:
In the Contents pane, ensure the feature layer and feature class check boxes are checked to display the labels.
  1. In the Label Class pane, configure the following parameters in the Expression box:
  • For Arcade, replace <field_name> with the name of the field to be displayed as labels. Replace <value> with the number of zeroes according to the number of digits. In this example, the expression is used to add leading zeroes to make five digits.
Text($feature["<field_name>"], '<value>')
Arcade expression configuration in the Expression box
  • For Python, replace <field_name> with the name of the field to be displayed as labels. Replace <value> with the number of zeroes according to the number of digits. In this example, the expression is used to add leading zeroes to make five digits.
[field_name].zfill(<value>)
Python expression configuration in the Expression box
  1. Click Verify to validate the expression.
  2. Click Apply to run the script.

The map below displays the data with leading zeroes in the labels.

Labels after adding leading zeroes

Article ID: 000031747

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 3 2

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options