ArcGIS Online

Create Custom Field Calculations Using Arcade Expressions

Arcade expressions offer a flexible way to work with your GIS data on-the-fly. You can use them to map your data, label features, configure a popup, and so much more. Now, you can now also use Arcade to calculate new fields directly into your hosted feature layers in ArcGIS Online.

Why use Arcade to calculate fields?

The ability to calculate fields in ArcGIS Online has been possible with SQL, which is great for large or synced datasets. However, calculating with Arcade is easy to learn, allows for more flexibility than SQL, and utilizes geospatial capabilities.

Arcade has been a great way to manipulate your data on-the-fly in your maps for a while now. But in some cases, you might need the results to be more permanent. For example, if you want to filter, chart, analyze, or export the results of an arcade expression, you would need the values to be built into the data table. You also need field values for advanced mapping techniques such as predominance and relationship mapping. This is where calculating a field with Arcade will help your workflows thrive.

Arcade allows you to access feature geometry, store constants and variables, and provide access to attribute values. You can utilize Arcade and its wide functionality to calculate new data-driven values. For example:

How to Calculate New Fields with Arcade in ArcGIS Online:

1) To start, choose to add a new field, or choose the field you want to calculate values for. This can be done from either the table view in Map Viewer or from the Data tab from your item description page. Choose Calculate from the field options

Tip: Using Calculate on existing fields with either SQL or Arcade will overwrite the existing data values. If you are worried about losing your original data, create a new field and calculate to that field instead.

 

2) Choose the Arcade option

3) Write your arcade expression. This example uses the Area geometry function to calculate population density.

Tip: Try your arcade expression within smart mapping to test the expression results first. This also allows you to see how well the attribute looks on a map. To learn the basics of mapping with Arcade, visit this blog or this Story Map tutorial.

 

4) Test your expression. If the test value looks correct, click OK to calculate your new field values.

Need inspiration?

The example above showed how to use a basic geometry function. Here are a few other examples that show arcade expressions and functions being used to calculate fields.

 

With the data below, I wanted to compare the number of people with a high school level degree or less to the population with above a high school education. To use the predominance mapping tool, and to show the values within a chart, I needed to use Arcade to combine multiple fields into two fields:

In this next example, I needed to fix text values that were in all caps by using the text function, Proper. With this change, I can easily use the new value within popups and labeling:

This example, inspired by this blog, calculates the ratio of land value and the improved value as a ratio. The input fields are text, and converted into numbers. This example uses multiple conversion functions as well as variables. By creating a new field, this value now be used within additional analysis, and also will allow me to filter my map by different values:

About the author

I am a Cartographic Product Engineer on the Living Atlas team at Esri. I work to create clear and concise stories about demographic data using cartography. I also build data layers and tutorials to help others create their own map masterpieces.

Connect:

Next Article

7 Reasons Why You Need ArcGIS Indoors

Read this article