Data Management

What's New in Arcade (June 2017)

Arcade has been popping up in more places with each release of ArcGIS, so it only makes sense to add more support for Arcade into the pop-up itself.  In this update of ArcGIS Online, we are introducing the concept of attribute expressions. You can leverage attribute expressions in pop-ups by defining an Arcade expression to create attributes for your pop-up.  You can use attribute expressions just like regular attributes to show information or create charts.  These attributes are calculated on the fly when you open a pop-up and are not stored as part of your layer’s data.  This allows you to do several interesting things to improve the presentation of your data. Below are just a few examples.

The screenshot below shows summary information from a water well database.  You’ll notice that the values for Depth to Bedrock and Static Water Level are both 0.00.  This is because both fields are numeric.  So, what does 0.00 mean? Does it mean bedrock is exposed at the surface or that the value was not recorded?  Clicking the link to get the PDF well log will show you immediately that the values were not recorded.

It would be nice to make that information obvious to any user exploring the map. Arcade can help. The Configure Pop-up pane now has a new section called Attribute Expressions where you can solve this problem by defining a new Arcade-based attribute. In this case, we added a simple expression to substitute 0.00 for the text “Not Recorded” and to append the unit of measure to the recorded value.  That expression looks something like this:

IIf($feature.DP_BEDROCK == 0, "Not Recorded", $feature.DP_BEDROCK+ " m")

Once that attribute expression is added to the pop-up, you can use it just like any other attribute in the popup. The result is a clearer message to the user about the data they’re looking at.

That’s a simple example. What about that PDF link?  The link was created using attribute expressions as well. In this case, we used part of the Well_ID field and the whole Well_ID field to build a quick link to the paper well log for each water well.

+ Left($feature.WELL_ID, 3) + "/" + $feature.WELL_ID + ".pdf"

Hopefully this is starting to pique your interest.  Let’s look at a few more quick examples using some monthly sales data. Using attribute expressions on this dataset with sales by month, we can quickly create new attributes in the pop-up to show additional metrics. For example, you might want to show annual sales, average monthly sales, performance, and best month figures for each sales person in an organization.

In this example, four additional metrics are created using attribute expressions. You can turn them on and off in the pop-up through the Configure Attributes section of the pop-up configuration.  Any new attribute expression is visible by default in the pop-up.

The result is a pop-up summarizing key metrics about the data that are always up to date as the dataset is updated and changes.

In addition to attribute expressions, we’ve made several improvements to the Arcade editor itself this release. The first improvement makes it easier to work with coded value domains. In Arcade, attributes by default return the value code and not the description name of the domain. This can lead to confusion when the code and name differ from one another. Now, if a field has a coded value we include a snippet shortcut on the Globals tab to insert the code snippet needed to compare the domain description name.

Additionally, if you modify the test value (by clicking the pencil icon) for a given attribute, we now show you the full list of coded value domain entries to make it faster to work with.

Continuing in the theme of saving you time, we’ve also added a new tab called “Existing” to the Arcade editor.  Under this tab, you’ll find all the existing expressions that have been authored for the layer, whether in the pop-up, the style options, labeling, or rotation.  This tab allows you to quickly copy an existing expression so that you can use it in another place where Arcade is supported.  For example, if you created a style in Arcade, you might want that value to show up in the pop-up.  The “Existing” tab speeds up the process.

Right now, attribute expressions will only work when using ArcGIS Online or with the latest JS API’s (either 3.21 or 4.4 coming very soon). However, you will gradually see them make their way to the entire platform in future releases. Attribute expressions are about giving you the flexibility to create great looking pop-ups with minimal work. We can’t wait to see you put attribute expressions to work in creative and interesting ways.

About the author

Product Engineer for ArcGIS Online and technology enthusiast.


Next Article

Engaging Volunteers for a Cause

Read this article