HOW TO

Remove leading text from a string using Arcade in ArcGIS Online

Last Published: February 2, 2024

Summary

In ArcGIS Online, leading text from a string in the attribute table can be removed to optimize data quality and facilitate more reliable geospatial analyses.

This article provides the workflow to remove leading text from a string field and populate the remaining text in a new field using an Arcade expression in the attribute table in ArcGIS Online.

The image below displays the Company field with the text string records.

Attribute table displaying field containing leading text to be removed.png

Procedure

  1. In ArcGIS Online, click the desired hosted feature layer. On the item details page, click the Data tab.
Note:
Skip to Step 3 if the script is run on an existing field.
  1. In the Table view, create a new field. Refer to ArcGIS Online: Add a field for instructions. Ensure String is selected from the Type drop-down list. In this example, a field named New_Company is created.
  2. Click the field header and select Calculate. In this example, New_Company is selected.
  3. In the Calculate Field dialog box, click Arcade.
  4. In the Arcade Calculator dialog box, specify the Expression field as follows:
var <variable1> = Find(' ', $feature.<field_name>, 0)
var <variable2> = Count($feature.<field_name>)
var <variable3> = <variable2> - <variable1>

return Right($feature.<field_name>, <variable3>)
  1. Replace <variable1>, <variable2>, and <variable3> with the desired variable names. In this example, fstSpace, strCount, and strDiff are used.
  2. Replace <field_name> with the name of the field from which the characters are to be removed. In this example, Company is used.
  1. Click Test to verify the expression, and click OK to apply the query.
    Label expression configuration.png

    The image below displays the New Company field populated with the values of the Company field without the leading text.

    Labels displayed after replacing comma from the field values with hyphen.png

Article ID: 000031838

Software:
  • ArcGIS Online

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

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options