Arcade to expressions

GratisGIS does not run Arcade. Common Arcade patterns translated into the expressions used by Filter and Calculate field steps, and what has no equivalent yet.

intermediate

GratisGIS does not run Arcade, but its expression language covers most of what Arcade expressions do, and accepts many Arcade spellings as they are. Web maps imported from ArcGIS bring their label and popup Arcade across as expression fields when it translates, and list what did not in the import report. Paste Arcade into any expression box and the builder offers to convert it.

This page translates common Arcade patterns.

Where each kind of Arcade goes

Arcade used forIn GratisGISNotes
Label expressionAn expression field, shown with {{expr.name}}Can read related records and other layers, which Arcade labels cannot.
Popup expression or attribute expressionAn expression field, picked in the popup
Calculate Field with ArcadeCalculate field step on a derived layerThe column is computed on every read.
Filter or definition expressionFilter step, or a filter on the map layerSee Filter.
Geometry functions (Area, Length)Calculate geometry stepLength, perimeter and area with a unit. See Calculate.
Spatial lookups (Intersects, FeatureSetByName)intersecting(layer('...')) and the other data functionsSee below.
Form calculations and relevanceForm conditional logicSee Conditional logic.

The expression language in one minute

  • Fields: {{status}}, or Arcade's $feature.status. Names are case-sensitive.
  • Text: single or double quotes.
  • Compare with == or =, != or <>, <, <=, >, >=.
  • Combine with AND or &&, OR or ||, NOT or !.
  • IN, BETWEEN, LIKE, IS NULL and CASE WHEN work as in SQL.
  • + adds numbers and joins text, as in Arcade.
  • Dates have functions for adding, differencing, extracting and formatting.

The full list is in the expression language reference.

Translating common patterns

Many Arcade function names work as they are: IIf, When, Decode, DefaultValue, IsEmpty, Mid, Find, Concatenate, DateAdd, DateDiff, Constrain, Upper, Lower, Round.

ArcadeGratisGIS expression
$feature.status$feature.status or {{status}}
$feature.a == 1 && $feature.b != 'x'the same
IIf($feature.acres > 5, 'Large', 'Small')the same, or if({{acres}} > 5, 'Large', 'Small')
When($feature.p == 1, 'High', $feature.p == 2, 'Medium', 'Low')the same
Decode($feature.code, 'A', 'Active', 'Other')the same
Concatenate([$feature.first, ' ', $feature.last])concat({{first}}, ' ', {{last}})
Count($feature.name) (text length)length({{name}})
IsEmpty($feature.owner)the same, or {{owner}} IS NULL
Round($feature.value, 2)the same
Text($feature.value, '#,###.00')format_number({{value}}, 2)
Text($feature.d, 'MMM D, Y')format_date({{d}}, 'MMM D, YYYY')
Number($feature.code)the same
Now(), Today()the same
DateDiff(Now(), $feature.d, 'days')the same
DateAdd($feature.d, 30, 'days')the same
Year($feature.d)the same
Month($feature.d)month({{d}}), which counts 1 to 12. Arcade counts 0 to 11.
Weekday($feature.d)weekday({{d}}), which is Monday 1 to Sunday 7. Arcade is Sunday 0 to Saturday 6.
Replace, Trim, Left, Right, Properthe same
Split($feature.s, ',')[1]split_part({{s}}, ',', 2), counting from 1
Area($feature, 'acres')area($feature, 'acres')
Length($feature, 'feet')length($feature, 'feet')

FeatureSets

ArcadeGratisGIS expression
FeatureSetByRelationshipName($feature, 'inspections')related('inspections')
FeatureSetByName($map, 'Hydrants')layer('Hydrants')
FeatureSetByPortalItem(portal, 'id', 0)layer('id'), or layer('id', 'sublayer')
Filter(fs, "status = 'open'")filter(rows, {{status}} == 'open')
Filter(fs, 'code = @code') with a variablefilter(rows, {{code}} == $feature.code)
OrderBy(fs, 'date DESC')order_by(rows, {{date}}, 'desc')
Top(fs, 5)top(rows, 5)
First(fs).namefirst(rows).name
Count(fs)count(rows)
Sum(fs, 'cost'), Mean, Min, Maxsum(rows, {{cost}}), avg, min, max
Distinct(fs, 'type') then Countcount_distinct(rows, {{type}})
Intersects(fs, $feature)intersecting(rows)
Contains($feature, fs) style point-in-polygoncontaining(rows) or within(rows)
Intersects(fs, Buffer($feature, 100, 'feet'))within_distance(rows, 100, 'feet')
Buffer, Intersects and a loop with Distance to find the closestnearest(rows) and distance_to(rows)
A loop building a text listlist(rows, {{name}}, ', ')

The loop-free forms run where the data is, so the same expression can fill a calculated column for every row of a large layer.

Notes:

  • Counting from 1. Positions in substr, index_of and split_part count from 1, as in SQL. Arcade counts from 0.
  • Empty values. {{owner}} == null is true for an empty owner, as in Arcade.

What has no equivalent yet

  • Variables, loops and user-defined functions. Most loops in Arcade FeatureSet code build a count, a total or a list, which the summary functions do directly.
  • Regular expressions.
  • Arcade in dashboards and data expressions. Dashboards are web apps, and their charts read layers and derived layers directly.