HOW TO

Apply Arcade conditional functions to NULL or NOT NULL values in ArcGIS Online

Last Published: May 10, 2024

Summary

Arcade conditional functions are useful in field calculations to generate attribute values based on specific conditions. A field can be populated based on the attributes of other fields that hold either NULL or NOT NULL values to organize and prevent invalid records.

This article describes the workflow to apply Arcade conditional functions to NULL or NOT NULL values in ArcGIS Online by performing a field calculation. In this example, the attributes are populated in the Compile field by referencing field values from Type, SchoolID, District, and City (if the type is Public).

Table displaying the attributes containing null and not null values

Procedure

  1. In ArcGIS Online, navigate to Content > My Content.
  2. Click the hosted feature layer. On the item details page, click the Data tab.
The Data tab.
  1. In the Table view, click the field header to populate and select Calculate. Alternatively, create a new field.
The Calculate option.
  1. In the Calculate Field dialog box, click Arcade.
The Calculate Field dialog box displaying the Arcade language option.
  1. In the Arcade Calculator dialog box, specify the following Arcade expression in the Expression section.
var <variable1> = $feature.<fieldName1>
var <variable2> = $feature.<fieldName2>
var <variable3> = $feature.<fieldName3>
var <variable4> = $feature.<fieldName4>

if (<variable1> == '<fieldValue>') {
    if (!isEmpty(<variable4>) && !isEmpty(<variable3>)) {
        return <variable4> + ' - ' + <variable3> }
    else if (!isEmpty(<variable4>)) {
        return <variable4> }
    else if (!isEmpty(<variable3>)) {
        return <variable2> + ', ' + <variable3> }
else {
    return null }
}
  1. Click Test to verify the expression.
  2. Click OK.
The Arcade Calculator dialog box.

Article ID: 000032370

Software:
  • ArcGIS Online

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options