Select to view content in your preferred language

Push a list of values to output dictionary

591
0
12-27-2022 02:14 PM
BClaridge
Occasional Contributor

I'm writing an arcade expression in a Dashboard to generate a table element- I have two tables I want to pull a few values from and combine into one final array.  One table has the attribute value in a field named 'BankfullWidthAvg' and the other has two fields (Indicator and value) where I want the 'FloodplainConnectivity' indicator value only.  Everything has a unique EvaluationID.

I think I need to first create a list of the values I want and then push them to a dictionary I can create a final FeatureSet from.  I'm getting the list output but can't get it to write to the output dictionary.  There's an invalid token somewhere and I'm not sure the CombinedTbls code is correct?  Thanks!

 

var p = 'https://arcgis.com/';
var Condtbl = FeatureSetByPortalItem(Portal(p),'dc8b1b885ba840f4b32b1d5776df5d72',0,['Project','EvaluationID','StreamName','BenchmarkGroup','value','Condition','Indicator','FieldEvalDate'],true);
var sql = "Indicator = 'FloodplainConnectivity'";
var CondtblFiltered = Filter(Condtbl,sql);

var Indtbl = FeatureSetByPortalItem(Portal(p),'97e9d82469194fab88e4193ba591fb72',0,['Project','PointID','EvaluationID','StreamName','DefaultBenchmarkGroup','BankfullWidthAvg'],true);

//Create a list of the fields from the two tables I want in final table
var List = []
for (var f in Indtbl){
Push(List, f.EvaluationID)
Push(List, f.Project)
Push(List, f.StreamName)
Push(List, f.BankfullWidthAvg)
}
for (var f in CondtblFiltered){
Push(List, f.EvaluationID)
Push(List, f.value)
}

//Push the values from the list to the final array

var CombinedTbls = []
for (var i in List){
Push(CombinedTbls, List[List[i]])
}

//Create a dictionary for output
var Dict = {
'fields': [{ 'name': 'Project', 'type': 'esriFieldTypeString' },
{ 'name': 'EvaluationID', 'type': 'esriFieldTypeString' },
{ 'name': 'StreamName', 'type': 'esriFieldTypeString'},
{ 'name': 'DefaultBenchmarkGroup', 'type': 'esriFieldTypeString' },
{ 'name': 'BenchmarkGroup', 'type': 'esriFieldTypeString' },
{ 'name': 'value', 'type': 'esriFieldTypeDouble' },
{ 'name': 'BankfullWidthAvg', 'type': 'esriFieldTypeDouble' },
{ 'name': 'Condition', 'type': 'esriFieldTypeString' },
{ 'name': 'Indicator', 'type': 'esriFieldTypeString' }],
'geometryType': 'esriGeometryPoint',
'features': List
};

return FeatureSet(Text(Dict))

0 Kudos
0 Replies