Expressions are used in the Append Data tool to calculate input layer fields using append layer field values. When you're not appending fields from the append layer, use expressions to specify how each feature will be populated. An Append Data expression should result in values of the same type as the field. Expression examples are included in the following sections.
The Append Data tool was introduced at 10.6.1 and can use Arcade expressions to append field values. Using Arcade, field names are formatted as $feature["field name"] or $feature.fieldname. The first option, $feature["field name"], is required when a field name includes a space. All examples below use this option.
Learn more about Arcade expressions
The following tools use Arcade expressions in GeoAnalytics Server:
- Reconstruct Tracks—Buffer expressions.
- Create Buffers—Buffer expressions.
- Join Features—Join expressions.
- Detect Incidents—Detect incidents using start and end expressions.
- Calculate Field—Calculate field values.
Legacy:
The ArcGIS GeoAnalytics Server extension is being deprecated in ArcGIS Enterprise. The final release of GeoAnalytics Server was included with ArcGIS Enterprise 11.3. These tools are available through ArcGIS Enterprise 11.3 and earlier versions.
Mathematical operation and function examples
Expressions can mathematically process numbers. The following table shows examples of available operations.
Learn more about mathematical operations and functions in Arcade
Operator | Explanation | Example |
---|---|---|
a + b | Returns the sum of a plus b. | fieldname contains a value of 1.5 $feature["fieldname"] + 2.5 4.0 |
a - b | Returns the difference of a minus b. | fieldname contains a value of 3.3 $feature["fieldname"]- 2.2 1.1 |
a * b | Returns the product of a times b. | fieldname contains a value of 2.0 $feature["fieldname"] * 2.2 4.4 |
a / b | Returns the quotient of a divided by b. | fieldname contains a value of 4.0 $feature["fieldname"] / 1.25 3.2 |
abs( a ) | Returns the absolute (positive) value of a. | fieldname contains a value of -1.5 abs($feature["fieldname"]) 1.5 |
log( a ) | Returns the natural logarithm (base E) of a. | fieldname contains a value of 1 log($feature["fieldname"]) 0 |
sin( a ) | Returns the trigonometric sine of a. The input is assumed to be an angle in radians. | fieldname contains a value of 1.5707 sin($feature["fieldname"]) 1 |
cos( a ) | Returns the trigonometric cosine of a. The input is assumed to be an angle in radians. | fieldname contains a value of 0 cos($feature["fieldname"]) 1 |
tan( a ) | Returns the tangent of a. The input is assumed to be an angle in radians. | fieldname contains a value of 0 tan($feature["fieldname"]) 0 |
sqrt( a ) | Returns the square root of a. | fieldname contains a value of 9 sqrt($feature["fieldname"]) 3 |
min( a, b ) | Returns the lowest valued number between a and b. | fieldname contains a value of 1.5, and a value of -3 min($feature["fieldname"], -3) -3 |
max( a, b ) | Returns the highest valued number between a and b. | fieldname1 contains a value of 1.5, and fieldname2 contains a value of -3 max($feature["fieldname1"], $feature["fieldname2"]) 1.5 |
constrain(<value>,<low>,<high>) | Returns the input value if it's within the constraining bounds. If the value is less than the low value, it returns the low value. If the value is greater than the high value, it returns the high value. | Example 1: constrain( $feature["distance"], 0, 10) Returns 0 if distance is less than 0, 10 if distance is greater than 10, and distance otherwise. Example 2: constrain($feature['Store dist'], 6, distance) Returns 6 if Store dist is less than 6, distance if Store dist is greater than distance, and Store dist otherwise. |
Text function examples
Append Data expressions can process text. The following table shows examples of available operations.
Learn more about text functions in Arcade
Operator | Explanation | Example | Result |
---|---|---|---|
concatenate(<values>, <separator>) | Concatenates values together and returns a string.
| fieldname contains a value of GeoAnalytics Concatenate ([$features["fieldname"], "is", "great!"], ' ') | GeoAnalytics is great! |
find(<searchText>, <text>, <startPos>) | Finds a string within a string. Wildcards are not supported.
| fieldname1 contains a value of 14NorthStreet and fieldname2 contains a value of North find($feature["fieldname2"], $feature["fieldname1"]) | 2 |
lower(<value>) | Makes a string lowercase.
| fieldname contains a value of GEOANALYTICS lower($feature["fieldname"]) | geoanalytics |
Text example using find and lower.
find(("north"), lower("146NorthStreet"))
Date function examples
Append Data expressions can process dates. The following table shows examples of available operations. In Arcade, month values range from 0 (January) to 11 (December), day values from the 1st to the 31st, hour values from 0 (12:00 a.m.) to 23 (11:00 p.m.), minute and second values from 0 to 59, and millisecond values from 0 to 999. Arcade dates return time values for the GeoAnalytics Server location.
Learn more about date functions in Arcade
Operator | Explanation | Example | Result |
---|---|---|---|
date(<value>, <month>, <day>, <hour>, <minute>) | Parses a value or set of values into a date string.
| fieldname contains a value of 1476987783555 Example 1: Date($features["fieldname"]) Example 2: Date(2017,0,14,0) Example 3: Date() | Example 1: 20 Oct 2016 11:23:03 am Example 2: 14 Jan 2017 12:00:00 am Example 3: Returns the current time |
DateDiff(<date1>, <date2>, <units>) | Subtracts two dates and returns the difference in the specified units.
| Example 1: DateDiff(Date(2017,1,14,0), Date()) Example 2: DateDiff(Date(2017,1,14,0), Date(), "Years") | Result will vary depending on when you run this command. Example 1: -20532129137 Example 2: -0.6546783768647119 |
Year(<dateValue>) | Returns the year of the given date.
| Example 1: fieldname is a field of type Date with a value of 09 Oct 2017 04:30:43 pm Year($feature["fieldname"]) Example 2: fieldname is a string field formatted as an ISO 8601 string with a value of 2012-09-27 | Example 1: 2017 Example 2: 2012 |
Logical function examples
In addition to simple mathematical expressions, more advanced functions, shown in the following table, can be used to apply buffer expressions.
Function | Explanation | Example | Result |
---|---|---|---|
iif(<condition>,<true value>,<false value>) | Returns one value if a condition evaluates to true and returns another value if that condition evaluates to false. <true value> and <false value> can be the following:
| iif($feature["field1"] > $feature["field2"], $feature["field1"], 0) iif($feature["field1"] > $feature["field2"], iif($feature["field2"] = 0, $feature["field3"], $feature["field4"]), 0) | Returns field1 if field1 is greater than field2, and 0 otherwise. Returns the result of the second iif function if field1 is greater than field2, and 0 otherwise. |
when(<expression1> , <result1> , <expression2> , <result2> , ... , <expressionN> , <resultN>, <default>) | Evaluates a series of expressions in order until one evaluates to true.
| when(($feature["field1"] + 10) > 1, 1,($feature["field2"] + 10) > 2 , 2, $feature["field3"]) | If field1 + 10 is greater than 1, returns 1. If not, checks if field2 + 10 is greater than 2. If yes, it returns 2. If not, it returns field3. |
decode(<conditional val> , <case1> , <result1>, <case2>, <result2>, ... <caseN>, <resultN>, <defaultValue> ) | Evaluates an expression and compares its value with subsequent parameters. If the expression matches, it returns the next parameter value. If none match, there is the option for the last parameter to be a default return value.
| decode($feature["field1"] + 3 , $feature["field1"], 1, $feature["field2"], 2, 0) | Compares equality between the conditional val field1 + 3 and case1 field1. If true, it returns 1. If false, it compares the equality between field1 + 3 and field2. If true, it returns 2; otherwise, it returns 0. |
Conditional operators
Conditional statements can use the following operators:
Operator | Explanation | Example | Results |
---|---|---|---|
a > b a < b | a is greater than b a is less than b | 10 > 2 | False |
a >= b a <= b | a is greater than or equal to b a is less than or equal to b | abs(-10) >= 10 | True |
a != b | a is not equal to b | abs(-3) != -3 | True |
a == b | a is equal to b | abs(-5) == 5 | True |
<condition1> || <condition2> | Condition 1 or condition 2 is met. | (abs(-5) == 5) || (10 < 2) | True |
<condition1> && <condition2> | Condition 1 and condition 2 are met. | (abs(-5) == 5) && (10 < 2) | False |