ArcGIS Dashboard Data Expression "unable to execute Arcade script"

283
2
Jump to solution
04-12-2024 01:39 PM
SarahW2799
New Contributor

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

 

 

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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));

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

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));
SarahW2799
New Contributor

Thank you!

0 Kudos