Frequently Asked Questions
You may find yourself asking, "Why did Esri bother writing its own language when it probably could have used others, like Python?"
This decision was made because we needed an expression language that met the following requirements:
- Lightweight and simple - A language with a small number of functions and an easy syntax.
- Portable - A language that can execute in multiple environments with the same syntax for web, desktop, and mobile apps.
- Secure - A language that doesn't have security vulnerabilities that open the door to malicious scripts.
- Geospatial first - A language that makes geospatial functions and capabilities first-class citizens.
Arcade is an expression language intended for use solely within the ArcGIS platform. It is not a standalone language intended for building apps or for executing expressions within other apps not supported by ArcGIS. It can only be executed within the context of a designated profiles, such as labeling, visualization, popups, calculation, and constraints.
For example, Arcade can be used to calculate values client-side for the popup.
// displays the % change between two attributes for the popup var pop2020 = $feature.POP_2020; var pop2010 = $feature.POP_2010; var perChange = ( ( pop2020 - pop2010 ) / pop2010 ); // implicitly casts the number as a string return Round( perChange ) + "%";
See the Getting started with Arcade page and other guide pages to learn more about when you can use Arcade.
You can use the version matrix to find the Arcade version corresponding to the ArcGIS product you're using. See the release notes to view the features new to each release. The documentation of each function also indicates the Arcade version in which the function was added. If no version is specified, then the function was added in the initial
1.0 release of Arcade.
Currently, you cannot execute Arcade expressions outside of a supported execution profile. If you have a use case for creating your own Arcade execution profile, then please send us feedback and describe in detail what you are trying to accomplish and how Arcade can help you.
We currently don't document a way to create your own Arcade profiles. If you have a need for new Arcade profiles (or environments for executing Arcade), then please send us feedback and describe in detail what you are trying to accomplish and how a new Arcade profile can help you.
The dollar sign
$ character prefixes all valid global variables in an Arcade profile. All profiles support the
$feature global, and some include the
$feature represents the feature currently executing the Arcade expression. You can reference attributes in the feature by using the
$feature.FieldName syntax and get its geometry using any geometry function.
// $feature gives you access to field values // so you can use them in calculations $feature.POPULATION / $feature.SQ_MILES; // Assume the $feature is a point geometry var featureGeometry = Geometry($feature); // returns the x-coordinate of the geometry featureGeometry.x
No. Arcade may only be executed in a supported Arcade profile.
You can use geometry functions in any execution profile. However, you should be aware that since Arcade expressions execute for each feature, using multiple geometry operations within the context of some profiles, such as
visualization, can be expensive and severely impact the performance of the application. Therefore, it may be more advisable to reserve certain geometry operations for other cases, such as the
The majority of functions may be used in any profile, but not all functions are designed for all profiles.
Some functions are reserved for specific profile(s). The documentation for each function indicates the valid profiles where it may be used. If a target profile is not specified in the documentation, then you can assume that the function may be used in any profile.
There are several different ways to handle
null values in your data. A common workflow is to replace an awkward blank spot in your popup with a coherent phrase or default placeholder. The IsEmpty() and DefaultValue() functions can conveniently help you handle these situations.
You can reference attribute data from a joined table using the square bracket syntax for referencing field names:
// data from a joined table var demVotes2016 = $feature["COUNTY_ID.VOTED_DEM_2016"]; var demVotes2012 = $feature["COUNTY_ID.VOTED_DEM_2012"]; // returns % change in votes from 2012 to 2016 Round( ( ( demVotes2016 - demVotes2012 ) / demVotes2012 ) * 100, 2);
You can access data from related tables using FeatureSet functions.
Yes. You can access data from other layers using the FeatureSet functions in profiles that support them.
You can find examples in the following places:
You can publicly share Arcade expression templates with others in the Esri/arcade-expressions GitHub repository. This repository is intended for sharing and maintaining reuseable Arcade expressions across all supported profiles.
Arcade expressions are portable as along as the functions used in the expression and the execution profile are supported in the versions of Arcade used by the apps sharing the same expression.
Another example is
$feature casting to
Geometry in geometry functions. In Arcade 1.4, the following expression is valid:
Area( $feature, "kilometers" )
But it is not valid in Arcade 1.3. Arcade 1.3 doesn't automatically cast a feature to a geometry, so you will need to cast the geometry yourself to ensure portability.
Area ( Geometry($feature), "kilometers" )
Also note that geometry functions weren't supported until Arcade 1.3, so neither of the expressions will work if you attempt to use them in an app that uses Arcade 1.2 or prior.
To ensure portability, you should try to use the latest version of Arcade as possible in each of your apps.
No. When working with multiple geometries using geometry functions, their spatial references must match. The spatial reference of all geometries must match the spatial reference of the map or service executing the expression as well.