Frequently asked question

Is it possible to perform calculations using values from another feature in the Calculate Field tool?

Last Published: May 28, 2025

It is possible to perform calculations using values from another feature in the Calculate Field tool in ArcGIS Pro. When running calculations on a field in an attribute table or a standalone table, the ArcGIS Arcade FeatureSetByName() and the FeatureSetByPortalItems() functions allow the retrieval of the values from fields in different tables. Use the FeatureSetByName() function for value retrieval between tables within ArcGIS Pro, and the FeatureSetByPortalItems() function for value retrieval with a connected portal, using either the ArcGIS Online organizational account or the ArcGIS Enterprise portal.

Retrieve values from another table or feature within ArcGIS Pro

When using the FeatureSetByName() function, the following parameters must be considered:

  • The location of the data. Use '$datastore' if the data is in the same geodatabase.
  • The feature or table name.
  • The field name(s). This parameter is optional. The function retrieves every field available if no field name is provided. This may affect processing time depending on the table size.
  • The geometry Boolean values (True or False). This parameter is optional. Setting the value to 'True' retrieves the feature’s complete geometry details, and setting it to 'False' retrieves the value as is. Setting the parameter to 'True' may affect processing time.

The function is displayed as follows:

FeatureSetByName(<data_location>,'<feature_name>', ['<field_name1>', '<field_name2>', ....] <geometry>);

The following is a sample working code to add the first value from another table into the current table in the Calculate Field tool:

var tbl = FeatureSetByName($datastore,"house",['Shape_Length'], False);
var feat = First(tbl)
return $feature.Shape_Length + feat.Shape_Length
Script sample for adding values from another feature in ArcGIS Pro

Retrieve values from another table in ArcGIS Online or the Enterprise portal.

When using the FeatureSetByPortalItem() function, the following parameters must be considered:

  • The Portal URL. The URL follows the connected portal set in ArcGIS Pro, either with an ArcGIS Online organizational account or an Enterprise portal.
  • The item ID of the selected feature or table.
  • The sublayer ID of the selected feature or table.
  • The field name(s). This parameter is optional. The function retrieves every field available if no field name is provided. This may affect processing time depending on the table size.
  • The geometry Boolean values (True or False). This parameter is optional. Setting the value to 'True' retrieves the feature’s complete geometry details, and setting it to 'False' retrieves the value just as is. Setting the parameter to 'True' may affect processing time.

The function is displayed as follows:

featureSetByPortalID(Portal(<Portal URL>, "<feature_ID>", "<sublayer_ID>”, ['<field_name1>', '<field_name2>', ...] <geometry>)

The following is a sample working code to count the number of features from another table in ArcGIS Online or Enterprise portal into the current table in the Calculate Field tool:

  • In ArcGIS Online
var feat = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'c43e270e9casdfasxcaedc6', 0, ['Direction'], false );

Count(feat);
  • In the ArcGIS Enterprise portal
var feat = FeatureSetByPortalItem(Portal(‘https://machine.domain.com/portal'), 'c43awsfvsdrvsaf7a009c27ad38fce96', 1, ['Direction', 'Signs'], false );

Count(feat);
Script sample for adding values from another feature from ArcGIS Online

Article ID: 000031106

Software:
  • ArcGIS Pro
  • ArcGIS Online
  • Portal for ArcGIS
  • ArcGIS Enterprise

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