<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Arcade expression returns FeatureSet but &amp;quot;Unable to execute Arcade script&amp;quot; displays in indicator in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-returns-featureset-but-quot/m-p/1625349#M11225</link>
    <description>&lt;P&gt;Try something like this, I think you've mostly got it:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Point to Portal
var p = Portal('https://maps.arcgis.com/')

// Create featureset
var fs = FeatureSetByPortalItem(p, '5c798c532ad5448ea9e973de8ddf8076', 2, ['State'], false)

var total = Count(fs)

var michigan = Count(Filter(fs, "State = 'Michigan'"))

// Calculate percent
var pct = IIf(total == 0, 0, Round((michigan / total) * 100, 1))

// Create dictionary to hold percent calculation
var newDict = {fields: [
    {name: 'Percent', type: 'esriFieldTypeDouble'}],
    geometryType: '',
    features: []
}

// Put percent calculation into dictionary
Push(newDict['features'], {attributes: {Percent: pct}})

// Create a featureset from the dictionary
return FeatureSet(Text(newDict))&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 20 Jun 2025 14:06:19 GMT</pubDate>
    <dc:creator>NicoleJohnson</dc:creator>
    <dc:date>2025-06-20T14:06:19Z</dc:date>
    <item>
      <title>Arcade expression returns FeatureSet but "Unable to execute Arcade script" displays in indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-returns-featureset-but-quot/m-p/1625039#M11224</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to create an indicator in ArcGIS Dashboards that display the percentage of features with a specific attribute value using an Arcade expression. I can see the correct result in the create new expression window, but once i click "done", the indicator displays: "Unable to execute arcade script"&lt;/P&gt;&lt;P&gt;For context:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I have a hosted feature layer with a field called "estado".&lt;/LI&gt;&lt;LI&gt;I want to calculate the percentage of those features where estado = 'Rechazada IPEEM/Archivo'.&lt;/LI&gt;&lt;LI&gt;Running the script in the create new expression window returns the FeatureSet correctly.&lt;/LI&gt;&lt;LI&gt;Log window doesn't display any warnings or errors.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="python"&gt;var capa = FeatureSetByPortalItem(
  Portal(''),
  '597723f82afb4031a8211a2a993c7688', // Feature layer ID
  0,
  ['estado']
);

var total = Count(capa);
var rechazadas = Count(Filter(capa, "estado = 'Rechazada IPEEM/Archivo'"));

var porcentaje = IIf(total == 0, 0, Round((rechazadas / total) * 100, 1));

return {
  fields: [
    { name: "porcentaje", type: "esriFieldTypeDouble" }
  ],
  geometryType: "",
  features: [
    {
      attributes: {
        porcentaje: porcentaje
      }
    }
  ]
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 12:20:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-returns-featureset-but-quot/m-p/1625039#M11224</guid>
      <dc:creator>JuanTomásMartinez</dc:creator>
      <dc:date>2025-06-19T12:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression returns FeatureSet but "Unable to execute Arcade script" displays in indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-returns-featureset-but-quot/m-p/1625349#M11225</link>
      <description>&lt;P&gt;Try something like this, I think you've mostly got it:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Point to Portal
var p = Portal('https://maps.arcgis.com/')

// Create featureset
var fs = FeatureSetByPortalItem(p, '5c798c532ad5448ea9e973de8ddf8076', 2, ['State'], false)

var total = Count(fs)

var michigan = Count(Filter(fs, "State = 'Michigan'"))

// Calculate percent
var pct = IIf(total == 0, 0, Round((michigan / total) * 100, 1))

// Create dictionary to hold percent calculation
var newDict = {fields: [
    {name: 'Percent', type: 'esriFieldTypeDouble'}],
    geometryType: '',
    features: []
}

// Put percent calculation into dictionary
Push(newDict['features'], {attributes: {Percent: pct}})

// Create a featureset from the dictionary
return FeatureSet(Text(newDict))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 20 Jun 2025 14:06:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-returns-featureset-but-quot/m-p/1625349#M11225</guid>
      <dc:creator>NicoleJohnson</dc:creator>
      <dc:date>2025-06-20T14:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression returns FeatureSet but "Unable to execute Arcade script" displays in indicator</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-returns-featureset-but-quot/m-p/1625729#M11229</link>
      <description>&lt;P&gt;You are returning a Dictionary, not a FeatureSet. You just need to wrap that Dictionary in the FeatureSet function&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var capa = FeatureSetByPortalItem(
  Portal(""),
  "597723f82afb4031a8211a2a993c7688",
  0,
  ["estado"]
);

var total = Count(capa);
var rechazadas = Count(Filter(capa, "estado = 'Rechazada IPEEM/Archivo'"));

var porcentaje = IIf(total == 0, 0, Round(rechazadas / total * 100, 1));

return FeatureSet(
  {
    fields: [{ name: "porcentaje", type: "esriFieldTypeDouble" }],
    geometryType: "",
    features: [{ attributes: { porcentaje: porcentaje } }]
  }
);&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 23 Jun 2025 14:51:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-returns-featureset-but-quot/m-p/1625729#M11229</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-06-23T14:51:49Z</dc:date>
    </item>
  </channel>
</rss>

