HOW TO

Add leading zeros to an attribute table field in ArcMap

Last Published: July 27, 2023

Summary

Instructions provided describe how to add leading zeros to values in a number or text field in an attribute table in ArcMap.

A desired number of digits must be set for the field before adding the leading zeros. For example, for a field containing numbers from 0 to 200, and the desired number of digits is set to be 3, value one is displayed as 001, value 99 is displayed as 099, and value 200 is displayed as 200. This allows all the values in the field to consist of a same number of digits.

Procedure

  1. Add a feature class or shapefile to ArcMap.
  2. Right-click the layer in the Table Of Contents > Edit Features > Start Editing.
  3. Open the attribute table by right-clicking the layer in the Table Of Contents > Open Attribute Table.
  4. Click Table Options > Add Field.
Image of accessing the add field window from the attribute table
  1. In the Add Field window, name the field, Select Text in the Type drop-down menu, and specify the desired field length.
An image of the Add Field window
  1. Populate the newly created field with the desired values. For information related to populating a field using the Field Calculator tool, refer to ArcMap: Fundamentals of field calculations and ArcMap: Using the Calculate Field tool.
  2. Right-click the newly created field > Field Calculator.
  3. In the Field Calculator window, select Python as the parser.
  4. Under the Fields section, double-click the newly created field.
  5. Under the Type section, select String.
  6. In the Functions section, scroll-down the list and double-click .zfill().
  7. Specify the desired number of digits in the brackets of .zfill(). The following is a sample expression:
a sample expression for zfill()
  1. Click OK.

Article ID:000013035

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic