HOW TO

Specify the number of decimal places to round to in labels for numbers in string fields in ArcGIS Online

Last Published: January 20, 2022

Summary

When configuring pop-ups in ArcGIS Online, custom expressions written in the Arcade expression language are available. Expressions can be used to create and display new information from existing fields in the layer.

This article provides the steps to round a numeric value to a set number of decimal places for string fields in a pop-up via ArcGIS Online Map Viewer.

Procedure

  1. Open the map in Map Viewer. Click Layers, and select the <layer name> with the pop-up for editing.
The Map Viewer Contents (dark) toolbar with the Layers tab
  1. Click Configure pop-ups > Manage expressions.
The Map Viewer Pop-ups pane used to navigate to the Map Viewer Pop-up expressions pane
  1. Click + Add expression to open the Arcade Expression dialog box.
The Map Viewer Pop-up expressions pane with the Add expression icon
  1. The sample Arcade expression below describes the functions specified to round the number values in the Notes field.
    1. The var str variable is used to allow multiple functions in one Arcade expression.
    2. The Mid text function returns a specified number of characters from the middle of a text value.
    3. The Round mathematical function rounds the number values to the given number of decimal places.
    4. The Left text function returns a specified number of characters from the beginning of a text value.
    5. The Right text function returns a specified number of characters from the end of a text value.
var str=Mid($feature.Notes, 21, 7)
var str1=Round(str, 2)
Left($feature.Notes, 21)+str1+Right($feature.Notes, 2)
  1. Rename the Custom field name to Notes. Click OK.
The Map Viewer Arcade expression dialog box to define expressions and rename the expression
  1. Click the Previous button above the newly created Arcade expression in the Pop-up expressions pane.
The Map Viewer Pop-up expressions pane with the newly added expression
  1. Click Fields list to expand the list of fields displayed in the pop-ups, and click Select fields.
The Map Viewer Pop-ups pane displaying the location of the Fields list section
  1. Uncheck the Notes field without the Arcade expression, and check the Notes field with the Arcade expression. Click Done.
The Map Viewer Select fields pane to select fields to be displayed in the pop-up

The image below demonstrates the pop-up display of the standard Notes field.

The Map Viewer pop-up without the Arcade expression for the Notes field

The image below demonstrates the pop-up display of the Notes field with the Arcade expression.

The Map Viewer pop-up with the Arcade expression for the Notes field

Article ID: 000026872

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

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options