Hi there,
I'm was asked to create an indicator in an ArcGIS Dashboard that relied on counts from multiple layers in the map. After some googling, I came up with the code below (redacted item IDs since this data is confidential).
When I run it in the expression builder, it gives me the output "number: 27" which is correct. However when I click done, I see a little error triangle with an ! telling me "Unable to execute Arcade script".
I tried to use the solution from this post: Solved: ArcGIS Dashboard Data Expression, "unable to execu... - Esri Community but it didn't work or I didn't execute the solution correctly. Any ideas? Thank you!
var features_riley = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"####"
);
var features_ottawa = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_dickson = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_washington = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_republic = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_saline = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_cloud = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_marshall = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_clay = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var features_geary = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"###"
);
var total = (Count(Filter(features_ottawa, "Status IS NOT NULL")) +
Count(Filter(features_marshall, "Status IS NOT NULL")) +
Count(Filter(features_riley, "Status IS NOT NULL")) +
Count(Filter(features_dickson, "Status IS NOT NULL")) +
Count(Filter(features_washington, "Status IS NOT NULL")) +
Count(Filter(features_republic, "Status IS NOT NULL")) +
Count(Filter(features_saline, "Status IS NOT NULL")) +
Count(Filter(features_cloud, "Status IS NOT NULL")) +
Count(Filter(features_clay, "Status IS NOT NULL"))) /
(Count(features_ottawa) +
Count(features_riley) +
Count(features_dickson) +
Count(features_washington) +
Count(features_republic) +
Count(features_saline) +
Count(features_cloud) +
Count(features_marshall) +
Count(features_clay) +
Count(features_geary)) *
100;
var result = Round(total, 0);
return result
Solved! Go to Solution.
A Data Expression has to return a FeatureSet
//var result = Round(total, 0);
//return result
var Dict = {
'fields': [
{'name': 'Result', 'type': 'esriFieldTypeInteger'}],
'geometryType': '',
'features': []};
// fill the data schema with the data
Dict.features[0] = {
'attributes': {
'Result': Round(total, 0)
}}
// return the featureset
return FeatureSet(Text(Dict));
A Data Expression has to return a FeatureSet
//var result = Round(total, 0);
//return result
var Dict = {
'fields': [
{'name': 'Result', 'type': 'esriFieldTypeInteger'}],
'geometryType': '',
'features': []};
// fill the data schema with the data
Dict.features[0] = {
'attributes': {
'Result': Round(total, 0)
}}
// return the featureset
return FeatureSet(Text(Dict));
Thank you!