AnsweredAssumed Answered

Use Arcade Expression to get the values of a related table to use later in a Chart within Pop-ups

Question asked by andres.echeverri@beachenergy.com.au on Jun 22, 2020
Latest reply on Jun 24, 2020 by xander_bakker

Hi All

I was wondering if someone could help me with this. I am trying to use a similar approach that have been suggested by Xander Bakker to use the Filter function to get an array to use later in a chart. I have a hosted Feature Layer (Points) with the location of some wells. And I have an additional Table which has the "well" field (string field) in common with the hosted feature layer. From this table I was looking to pull out a couple of fields (oil production and date) to produce a Chart and add this chart to the Pop-up. The code in Arcade that I have is this one (from one previous post):

// first read out the well field of the Well layer
var well_name = $feature.well;
// access the table Monthly Production
var tbl = FeatureSetByName($map,"FL_SA_PEPS_DATA - MonthlyProduction");
// create a sql expression to query on well
var sql = "well = '" + well_name + "'";
// filter the table using the sql expression
var related_data = Filter(tbl, sql);
// count the resulting records
var cnt = Count(related_data);

// initiate a variable to hold the result
var result = "Related records: " + cnt;;

// check if there are related records found for the current ID
if (cnt > 0) {
    // loop through related records
    for (var row in related_data) {
        // read some data and create the line you want
       
        //add the line to the result
       result += TextFormatting.NewLine + row.oil__m3_;
    }
}


// return the result
return result;

 

With that code, I am able to get the list of dates or oil production and display those in the pop-up as text. Is it possible to use this as an array or sort of field to use them for the chart creation?. I can't see the result as an input for the chart.  I tried with this variant from other post: 

 

// initiate a variable to hold the result
var result = 0;

// check if there are related records found for the current ID
if (cnt > 0) {
    // loop through related records
    for (var row in related_data) {
       //add the line to the result
       result += row.oil__m3_;
    }
}

In this case, I got a single number, which then I can see as an input to create the chart, but is only a single number and not an array or table. Not sure what approach should I do?. Is something possible to do?. I am working in Portal for ArcGIS  10.7. Any help would be much appreciated.

 

Thanks,

 

Andres

Outcomes