Hello,
I am trying to use an arcade expressions to combine three feature layers (pt, line, polygon) into one data table to graph a shared attributes. I have found many examples of others that have successfully deployed this idea using the information in this link. https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/CombineMultipleLayers(SerialChart).md
I am not an arcade expert so I have been trying to follow this code and replace their attributes/ names with mine. Unfortunately I keep getting a errors. Specially "Execution Error:json" which does not mean much to me. I am wondering if anyone would be able to help figure out where I am going wrong. Here is the code that I have come up with following the github link.
Any advice or suggestions would be awesome!
Thanks in advance
var portal = Portal('PORTAL_URL');
var point = GroupBy(FeatureSetByPortalItem(
portal,
'FEATURE_ID',
0,
['RBU','CatCode28'],
false),
['RBU'],
[
{ name: 'CatCode28_point', expression: 'Point_CatCode28', statistic: 'SUM' },
]
);
var line = GroupBy(
FeatureSetByPortalItem(portal,'eba1d0d180a0419499566e4aa1336eea',0,
['RBU','CatCode28'],
false),
['RBU'],
[
{ name: 'CatCode28_line', expression: 'Line_CatCode28', statistic: 'SUM' },
]
);
var poly = GroupBy(
FeatureSetByPortalItem(portal,'111b954c606045e18180d507fcc40aef',0,
['RBU','CatCode28'],
false),
['RBU'],
[
{ name: 'CatCode28_poly', expression: 'Poly_CatCode28', statistic: 'SUM' },
]
);
// Create empty array for features, feat object to populate array
var features = [];
var feat;
// Loop through each of the three FeatureSets and populate feature array.
for (var p in point) {
feat = {
attributes: {
type: 'Points',
RBU: p['RBU'],
count_of_found: SUM(p['CatCode28_point']),
},
};
Push(features, feat);
}
for (var l in line) {
feat = {
attributes: {
type: 'Line',
RBU: l['RBU'],
count_of_found: SUM(l['CatCode28_line']),
},
};
Push(features, feat);
}
for (var g in polygon) {
feat = {
attributes: {
type: 'Polygon',
RBU: g['RBU'],
count_of_found: SUM(g['CatCode28_poly']),
},
};
Push(features, feat);
}
var combinedDict = {
fields: [
{ name: 'RBU', type: 'esriFieldTypeString' },
{ name: 'CateCode28', type: 'esriFieldTypeString' },
{ name: 'count_of_found', type: 'esriFieldTypeInteger' },
],
geometryType: '',
features: features,
};
// Return dictionary cast as a feature set
return FeatureSet(Text(combinedDict));