HOW TO

Display fields from another table in the pop-up window

Last Published: September 8, 2025

Summary

This article shows how to use Arcade to display data from another table containing a common field in a layer's pop-up window, in ArcGIS Pro and in ArcGIS Online or ArcGIS Enterprise. This can be a related table for example, but not necessarily.

Procedure

In ArcGIS Pro

  1. Right-click the layer, and click Configure Pop-ups.

  1. From the Arcade drop-down, select Text Template:

  1. Enter the following code, adapted for your data by replacing table with the “related” table, field_table with the common field in the table, field_class with the common field in the feature class, field1_table with a first field to be retrieved from the related table, field2_table with a second field to be retrieved from the related table.
var related_table = FeatureSetByName($datastore, "table");
var filter_query = "field_table= '" + $feature["field_class"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);

var output = "";
if (related_data_filtered_count > 0) {
	output = "Total of " + related_data_filtered_count + " records : ";
	for (var related_data_row in related_data_filtered) {
		output += '<br>' + related_data_row.field1_table+ " - " + related_data_row.field2_table;
	}
} else {
	output = "No Related Records...";
}

return {
	type : 'text',
	text : output
}
Note:
By adding + related_data_row.fieldX_table +', ' to line 10, you can add the number of fields you want from the second table.

An example pop-up is shown in the following image:

In Map Viewer 

Publish the expression after configuring it in ArcGIS Pro as described above, or click Add content in the pop-up window and click Arcade.

  1. Paste the same code as above. A typical result is shown in the next image.

In Map Viewer Classic

  1. Click the configuration, and click Configure Pop-up.

  1. Under Attribute Expressions, click Add.

  1. Paste the following code:
var related_table = FeatureSetByName($datastore, "table");
var filter_query = "field_table= '" + $feature["field_class"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);

var output = "";
if (related_data_filtered_count > 0) {
    output = "Total of " + related_data_filtered_count + " records : " + TextFormatting.NewLine;
    for (var related_data_row in related_data_filtered) {
        output +=  related_data_row.field1_table+ " - " + related_data_row.field2_table +', ' + TextFormatting.NewLine;
    }
} else {
    output = "No Related Records...";
}

return output
Note:
The output is slightly different from the previous code in that text is returned rather than a JSON block, and it uses the TextFormatting.NewLine line break, which does not work on ArcGIS Pro 3.X before version 3.3 (BUG-000162232), as the <br> code doesn't work in Map Viewer Classic.
  1. Configure the pop-up window display to reflect your expression. An example is shown in the following image:

Bonus

Since we do not really use the relationship class, but rather link layers via common field values, we can link another table to this related table.

For example, it is possible to display the departments that make up a region, then the communes for each of these departments:

//First related table
var related_table = FeatureSetByName($datastore, "departments");
//Second related table
var related_related_table = FeatureSetByName($datastore, "communes");

//Filter query on the first related table with the feature class field
var filter_query = "region_name= '" + $feature["name"] + "'";
//Filtered data from the first related table
var related_data_filtered = Filter(related_table, filter_query);
//Count of the filtered data from the first table
var related_data_filtered_count = Count(related_data_filtered);

//Output initialization
var output = "";

//Check if data filtered exist from the first related table 
if (related_data_filtered_count > 0) {
  //Write in the output the number of data filtered
  output = "Total of " + related_data_filtered_count + " records : " + "<br>";
  
  //Browse the rows of the first table
  for (var related_data_row in related_data_filtered) {
    //Write in the output the data from the selected fields from the first table
    output +=  related_data_row.department_number+ " - " + related_data_row.department_name +', ' + '<br>';
        
    //Filter query on the second related table with the field from the first related table
    var related_filter_query = "dept_name= '" + related_data_row.department_name + "'";
    //Filtered data from the second related table
    var related_related_data_filtered = Filter(related_related_table, related_filter_query);
    //Count of the filtered data from the second table
    var related_related_data_filtered_count = Count(related_related_data_filtered);
        
    //Check if data filtered exist from the second related table
    if (related_related_data_filtered_count > 0) {
      //Browse the rows of the second table
      for (var related_related_data_row in related_related_data_filtered) {
        //Write in the output the data from the selected fields from the second table
        output +=  "    " + related_related_data_row.commune_name+', ' + '<br>';
      }
    }else{
      //If no row selected in second table, write nothing
      output += "";
    }
  }
} else {
  //If no row selected in first table, write that there is no data
  output = "No Related Records...";
}

return { 
  type : 'text', 
  text : output
}

An example result in ArcGIS Pro is shown in the next image:

Article ID: 000035545

Software:
  • ArcGIS Pro
  • ArcGIS Online
  • 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