HOW TO

Calculate the count of non-empty cells across fields using Arcade in ArcGIS Online and Portal for ArcGIS

Last Published: June 20, 2023

Summary

In ArcGIS Online and Portal for ArcGIS, associated information can be recorded in the fields of hosted feature layers. To ensure efficient data analysis, it is sometimes necessary to check that cells are not empty and each contains a value. The Arcade expression provided in this article can be used to return the count of non-empty cells across fields for records in a hosted feature layer.

Four fields are used in this example to calculate the count of non-empty cells. Cells of certain records are empty, while others contain values equal to or greater than zero.

image.png

Procedure

  1. Log in to ArcGIS Online or Portal for ArcGIS and open the hosted feature layer's item details page.
  2. On the item details page, click Data.
  3. In the Table view, click Options image.png , and select Add Field to create a new field to populate the output.
    1. In the Add Field window, for Field Name, specify a name for the new field. In this example, the field name is report_check.
    2. For Type, select Double.
    3. Click Add New Field.
  4. Click the header of the new double field, and select Calculate.
  5. In the Calculate Field window, click Arcade.
  6. In the Arcade Calculator window, configure the following Arcade expression in the Expression box. Replace <fieldName> with the name of the fields to be included in the calculation.
var reportCount = 0

if($feature["<fieldName"] != null) { reportCount += 1 }
if($feature["<fieldName"] != null) { reportCount += 1 }
//add more fields as required

return reportCount

This is the Arcade expression used in this example.

var reportCount = 0

if($feature["Morning_TrafficReport"] != null) { reportCount += 1 }
if($feature["Midday_TrafficReport"] != null) { reportCount += 1 }
if($feature["Evening_TrafficReport"] != null) { reportCount += 1 }
if($feature["Night_TrafficReport"] != null) { reportCount += 1 }

return reportCount
  1. Click OK.

After running the Arcade expression, the output is generated in the new field. In this example, the only record with four non-empty cells is the record associated with Tun Razak Rd. where the output shows '4', matching the number of fields calculated.

image.png

Article ID: 000030610

Software:
  • ArcGIS Online
  • Portal for ArcGIS

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