PROBLEM

Unable to calculate text fields containing the percent sign

Last Published: September 15, 2023

Description

In ArcGIS Pro, the Calculate Field tool fails to execute mathematical calculation on a field when the values contain the percent sign (%).

The text field containing the percent characters in the attribute table.

Cause

The values containing the percent sign, %, are stored in a text data type field. Mathematical calculation cannot be executed in a text data type field.

Solution or Workaround

To resolve this issue, populate a new numeric field with the values and remove the percent (%) sign. Use the Percentage number format on the numeric field to retain the percent sign in the values.

  1. Open the ArcGIS Pro project.
  2. Open the attribute table of the feature layer containing the text field with the percent values and sign.
  3. Create a new numeric field with the Percentage number format.
    1. In the attribute table, click Add to add a new field.
    2. In the Fields view, name the field and apply a numeric data type with the Percentage number format to the field. Refer to ArcGIS Pro: Format numeric and date fields for instructions. In this example, the test_field with the Double data type and the Percentage number format is created.
Double data type and the Percentage number format applied for a field in the Fields view.
  1. Populate the new numeric field with data from the text field and remove the text with the percent (%) value using the Python rstrip() method.
    1. In the attribute table, right-click the field and select Calculate Field.
    2. In the Calculate Field pane, select Python 3 for the Expression Type parameter.
    3. In the Expression box, copy and insert the following code. Replace <my_text_field> with the text field containing the percent sign. In this example, the Rate field is used.
!<my_text_field>!.rstrip("%")
    1. Click Apply.
The Python expression in the Calculate Field pane.

Demonstrated below is the populated numeric field in the attribute table. The values are numeric data types with the percent sign displayed and can be used for mathematical calculation.

The attribute table with the populated numeric field.

Article ID: 000031136

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

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