HOW TO

Populate a feature layer field based on attributes of another using Arcade in ArcGIS Online

First Published: February 22, 2024
Last Published: April 7, 2026

Summary

In ArcGIS Online, fields in a layer can be populated with attribute values from another feature layer using an Arcade expression. This method is useful in enhancing data integrity and enabling synchronized analysis across layers.

In this article, two feature layers named Cities and ClimateData are used. The Cities feature layer contains two fields named CityAddress and ClimateLocationID. The ClimateData feature layer also contains two fields named ClimateAddress and LocationID. When the CityAddress field values match those of the ClimateAddress, the LocationID values are automatically populated in the ClimateLocationID field.

The attribute tables below display the fields in the Cities and ClimateData feature layers.

Attribute table displaying the Cities feature layer
Attribute table displaying the ClimateData feature layer

Procedure

  1. Log in to ArcGIS Online and click Content > My content.
  2. Click the hosted feature layer to open the item page, and click theĀ Data tab.
  3. On the Table page, click the Layer drop-down list and select the layer.
  4. In the header of the field to populate, click the Options button and select Calculate. In this example, the ClimateLocationID field is used.
The Table page of the Data tab
  1. On the Calculate field page, select Arcade and click Next.
  2. Under Arcade expression, specify the expression as follows:
var <variable1> = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '<Item_ID>', <layer_index>, ['*'], false);
  1. Replace <variable1> with the intended variable name. In this example, climateDataLayer is used.
  2. Replace <Item_ID> with the item ID of the hosted layer.
  3. Replace <layer_index> with either the value 0 or 1. The first layer has an index of 0, while the second layer has an index of 1. In this example, 0 is used as the first layer is to be populated.
var <variable2> = $feature['<field_name1>']; 

for (var<variable3> in <variable1> ) {
 var <variable4> = climateFeature['<field_name2>'];
 
    if <variable2> == <variable4>) {
        return <varibale3>['<field_name3>'];
    }
}

null
  1. Replace <variable2>, <variable3>, and <variable4> with the preferred variable names. In this example, cityAddress, climateFeature, and climateAddress are used.
  2. Replace <field_name1> with the field name from the first feature layer. In this example, CityAddress is used.
  3. Replace <field_name2> with the field name from the second feature layer. In this example, ClimateAddress is used.
  4. Replace <field_name3> with the field name from the second feature layer to pull the field values. In this example, LocationID is used.

Below is the full working code of the Arcade expression.

var climateDataLayer = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'fd3161f30d6f47aba8b58f6fcb5ed488', 0, ['*'], false);

var cityAddress = $feature['CityAddress']; 

for (var climateFeature in climateDataLayer) {
    var climateAddress = climateFeature['ClimateAddress'];

    if (cityAddress == climateAddress) {
        return climateFeature['LocationID']; 
    }
}

null
  1. Click Run to verify the expression, and click Run calculation to apply the query.
Arcade expression configuration

The attribute table below displays the ClimateLocationID field of the Cities feature layer populated with values from the LocationID field of the ClimateData feature layer when the CityAddress field values match the ClimateAddress.

ClimateLocationID field populated by the values of the LocationID field

Article ID: 000031934

Software:
  • ArcGIS Online

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options