<?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 in Dashboard runs in testing, then Unable to execute Arcade script appears in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495378#M9834</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;**Updated GroupBy expression&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');

// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;

// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating'], true);


function Memorize(fs) {
  var fieldList = Schema(fs)['fields'];
  Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
  var temp_dict = {
    fields: fieldList,
    geometryType: '',
    features: []
  }

    for (var f in fs) {
    var attrs = {}
    for (var attr in f) {
      attrs[attr] = f[attr]
    }
    attrs['collision_year'] = Year(f['date'])
    Push(
      temp_dict['features'],
      {attributes: attrs}
    )
  }

return FeatureSet(theDict);

var newFS = Memorize(fs)
var summaryFS = GroupBy(newFS, 'collision_year',
  [
    {name: 'Total Deaths', expression: 'number_dead', statistic: 'SUM' }, 
    {name: 'Total Injuries', expression: 'gis_incapacitating', statistic: 'SUM' }  ]);

return summaryFS;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2024 14:53:52 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2024-06-20T14:53:52Z</dc:date>
    <item>
      <title>Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490860#M9796</link>
      <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to determine why this arcade expression runs during testing, but then when I click "done" and go back to the "Select a layer" page to select the expression to use in a bar chart the data expression text is grayed out with an alert saying "Unable to execute Arcade script".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've included my script below for reference, I would appreciate any assistance or explanation why this isn;t working as intended.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;// sets portal url&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;cobportal&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Portal&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;A href="https://bloomingtonin.maps.arcgis.com/" target="_blank"&gt;https://bloomingtonin.maps.arcgis.com/&lt;/A&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// assign Crash Dataset variables&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;crashDatasetID&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;'50b2634c8c9443f58cd004f1138ef7ea'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;crashLayerID&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// assign FeatureSet variables&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;crashFs&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeatureSetByPortalItem&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;cobportal&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;crashDatasetID&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;crashLayerID&lt;/SPAN&gt;&lt;SPAN&gt;, [&lt;/SPAN&gt;&lt;SPAN&gt;'number_dead'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'gis_incapacitating'&lt;/SPAN&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// Initialize counters&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;totalDeaths&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;totalInjuries&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// Iterate through the FeatureSet and calculate totals&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;crash&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;crashFs&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;IsEmpty&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;crash&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;number_dead&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;crash&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;number_dead&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;totalDeaths&lt;/SPAN&gt;&lt;SPAN&gt; += &lt;/SPAN&gt;&lt;SPAN&gt;crash&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;number_dead&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;IsEmpty&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;crash&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;gis_incapacitating&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;crash&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;gis_incapacitating&lt;/SPAN&gt;&lt;SPAN&gt; == &lt;/SPAN&gt;&lt;SPAN&gt;'Yes'&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;totalInjuries&lt;/SPAN&gt;&lt;SPAN&gt; += &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// Return the results as an array&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;totalDeaths&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;totalInjuries&lt;/SPAN&gt;&lt;SPAN&gt;];&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Jun 2024 18:29:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490860#M9796</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-12T18:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490874#M9797</link>
      <description>&lt;P&gt;Dashboard data expressions require a featureset to be returned, but you are returning an array. You may want to create a featureset that has a category and a count field, and populate those fields with your totals. So I imagine you'll want to end up with a featureset "table" that looks like this in order to make a bar chart from it.&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;Category&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;Count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Total Deaths&lt;/TD&gt;&lt;TD width="50%"&gt;###&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Total Injuries&lt;/TD&gt;&lt;TD width="50%"&gt;###&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;A href="https://doc.arcgis.com/en/dashboards/latest/get-started/create-data-expressions.htm" target="_blank"&gt;Create a data expression—ArcGIS Dashboards | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 18:51:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490874#M9797</guid>
      <dc:creator>marksm_macomb</dc:creator>
      <dc:date>2024-06-12T18:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490889#M9798</link>
      <description>&lt;P&gt;A data expression must return a FeatureSet.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');

// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;

// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating'], true);

// Initialize counters
var totalDeaths = 0;var totalInjuries = 0;

// Iterate through the FeatureSet and calculate totals
for (var crash in crashFs) {
  if (IsEmpty(crash.number_dead) == false &amp;amp;&amp;amp; crash.number_dead &amp;gt; 0) {
    totalDeaths += crash.number_dead;
    }
    if (IsEmpty(crash.gis_incapacitating) == false &amp;amp;&amp;amp; crash.gis_incapacitating == 'Yes') {
      totalInjuries += 1;
      }
      }

// Return the results as a FeatureSet
var theDict = {
  'fields': [
    {'name':'TotalDeaths', 'type':'esriFieldTypeInteger'},
    {'name':'TotalInjuries', 'type':'esriFieldTypeInteger'}
  ],
  'geometryType': '',
  'features': [{
    'attributes': {
      'TotalDeaths': totalDeaths,
      'TotalInjuries': totalInjuries
     }
  }]
};
return FeatureSet(theDict);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 18:57:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490889#M9798</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-12T18:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490903#M9800</link>
      <description>&lt;P&gt;I am pretty new to Arcade, how would you group the above output by year? I have a collision_date field where the year could be extracted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 19:12:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1490903#M9800</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-12T19:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491022#M9804</link>
      <description>&lt;P&gt;You can do that with the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#groupby" target="_self"&gt;GroupBy&lt;/A&gt; function. Esri has a &lt;A href="https://github.com/Esri/arcade-expressions/tree/master/dashboard_data" target="_self"&gt;GitHub site&lt;/A&gt; with data expression samples, with &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/GroupByMultiStats(List).md" target="_self"&gt;one&lt;/A&gt; on GroupBy.&lt;/P&gt;&lt;P&gt;You can add the year field to your FeatureSet using a modification of &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;'s &lt;A href="https://community.esri.com/t5/arcgis-online-blog/improving-expression-performance-a-custom-function/ba-p/1288785/jump-to/first-unread-message" target="_self"&gt;Memorize&lt;/A&gt; function, then use GroupBy on it. This should work...but it's untested&lt;/P&gt;&lt;P&gt;**Edit...fixing field names. and more fixes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function Memorize(fs) {
  var fieldList = Schema(fs)['fields'];
  Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
  var temp_dict = {
    fields: fieldList,
    geometryType: '',
    features: []
  }

  for (var f in fs) {
    var attrs = {}
    for (var attr in f) {
      attrs[attr] = f[attr]
    }
    attrs['collision_year'] = Year(f['collision_date'])
    Push(
      temp_dict['features'],
      {attributes: attrs}
    )
  }

  return FeatureSet(Text(temp_dict))
}
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');

// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;

// assign FeatureSet variables

var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating', 'collision_date'], true);

var newFS = Memorize(crashFs);
var summaryFS = GroupBy(newFS, 'collision_year',
  [
    {name: 'number_dead', expression: 'TotalDeaths', statistic: 'SUM' }, 
    {name: 'gis_incapacitating', expression: 'TotalInjuries', statistic: 'SUM' }
  ]); 

return summaryFS;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping to use an SQL expression to define the year from the collision-date field to avoid using the Memorize function, but I can never seem to get more complicated SQL expressions to work.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 13:18:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491022#M9804</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-13T13:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491640#M9806</link>
      <description>&lt;P&gt;I'm a little confused about the order of this expression, is this appended to the original expression or run by itself? It did not run in Dashboards on its own.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 12:39:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491640#M9806</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-13T12:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491668#M9808</link>
      <description>&lt;P&gt;This is the whole expression. What do you get when you run in the code editor?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 13:01:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491668#M9808</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-13T13:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491696#M9809</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Test execution error: Unexpected token ')'.. Verify test data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 13:10:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491696#M9809</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-13T13:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491703#M9810</link>
      <description>&lt;P&gt;I had to fix an error in line 13. There was an extra parenthesis at the end.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 13:17:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491703#M9810</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-13T13:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491705#M9811</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Test execution error: Aggregation field not found. Verify test data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 13:24:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491705#M9811</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-13T13:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491717#M9812</link>
      <description>&lt;P&gt;Since I don't have access to your data, I've been using another &lt;A href="https://www.arcgis.com/home/item.html?id=25e36eb0d93d49859f73a4c98b1d3484" target="_self"&gt;dataset&lt;/A&gt; to do my testing. This version returns the expected FeatureSet. Can you modify it to use your data?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function Memorize(fs) {
  var fieldList = Schema(fs)['fields'];
  Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
  var temp_dict = {
    fields: fieldList,
    geometryType: '',
    features: []
  }

  for (var f in fs) {
    var attrs = {}
    for (var attr in f) {
      attrs[attr] = f[attr]
    }
    attrs['collision_year'] = Year(f['date'])
    Push(
      temp_dict['features'],
      {attributes: attrs}
    )
  }

  return FeatureSet(Text(temp_dict))
}// Fetches features from a public portal item
var fs = FeatureSetByPortalItem(
  Portal("https://www.arcgis.com"),
  // portal item id
  "25e36eb0d93d49859f73a4c98b1d3484",
  0, // layer id
  ["*"], // fields to include
  false // include or exclude geometry
);

var newFS = Memorize(fs)
var summaryFS = GroupBy(newFS, 'collision_year',
  [
    {name: 'Maximum magnitude', expression: 'magnitude', statistic: 'Max' }
  ]); 

return summaryFS;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 13:48:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1491717#M9812</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-13T13:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495319#M9830</link>
      <description>&lt;P&gt;Ken if you could provide some additional assistance I'd really appreciate it, still stuck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have now, but it's not correct:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;// sets portal url&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;cobportal&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Portal&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;A href="https://bloomingtonin.maps.arcgis.com/" target="_blank"&gt;https://bloomingtonin.maps.arcgis.com/&lt;/A&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// assign Crash Dataset variables&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;crashDatasetID&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;'50b2634c8c9443f58cd004f1138ef7ea'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;crashLayerID&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;// assign FeatureSet variables&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;crashFs&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeatureSetByPortalItem&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;cobportal&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;crashDatasetID&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;crashLayerID&lt;/SPAN&gt;&lt;SPAN&gt;, [&lt;/SPAN&gt;&lt;SPAN&gt;'number_dead'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'gis_incapacitating'&l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N&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; ]); &lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;summaryFS&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Jun 2024 13:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495319#M9830</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-20T13:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495347#M9832</link>
      <description>&lt;P&gt;When posting code, use the &lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;"Insert/Edit code sample"&lt;/A&gt; button. It makes your code easier to read and provide line numbers in your code.&lt;/P&gt;&lt;P&gt;Remember that I was using a different data set to show you how it would work, since I couldn't test it with your data and you were getting an execution error.&lt;/P&gt;&lt;P&gt;Do you still get that error when using this?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var summaryFS = GroupBy(newFS, 'collision_year',
  [
    {name: 'number_dead', expression: 'TotalDeaths', statistic: 'SUM' }, 
    {name: 'gis_incapacitating', expression: 'TotalInjuries', statistic: 'SUM' }
  ]); &lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Jun 2024 13:43:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495347#M9832</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-20T13:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495350#M9833</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');

// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;

// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating', 'collision_date'], true);

var summaryFS = GroupBy(newFS, 'collision_date',
  [
    {name: 'number_dead', expression: 'TotalDeaths', statistic: 'SUM' }, 
    {name: 'gis_incapacitating', expression: 'TotalInjuries', statistic: 'SUM' }
  ]); &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like this? it does not execute&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 13:54:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495350#M9833</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-20T13:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495378#M9834</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;**Updated GroupBy expression&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');

// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;

// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating'], true);


function Memorize(fs) {
  var fieldList = Schema(fs)['fields'];
  Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
  var temp_dict = {
    fields: fieldList,
    geometryType: '',
    features: []
  }

    for (var f in fs) {
    var attrs = {}
    for (var attr in f) {
      attrs[attr] = f[attr]
    }
    attrs['collision_year'] = Year(f['date'])
    Push(
      temp_dict['features'],
      {attributes: attrs}
    )
  }

return FeatureSet(theDict);

var newFS = Memorize(fs)
var summaryFS = GroupBy(newFS, 'collision_year',
  [
    {name: 'Total Deaths', expression: 'number_dead', statistic: 'SUM' }, 
    {name: 'Total Injuries', expression: 'gis_incapacitating', statistic: 'SUM' }  ]);

return summaryFS;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 14:53:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495378#M9834</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-20T14:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495394#M9835</link>
      <description>&lt;P&gt;Thank you so much for your continued assistance Ken, I really do appreciate it. Unfortunately, received this error:&amp;nbsp;&lt;SPAN&gt;Test execution error: '}' expected.. Verify test data. It doesn't like somethin with line 40&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 15:12:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495394#M9835</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-20T15:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495410#M9836</link>
      <description>&lt;P&gt;A few fixes I missed&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');

// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;

// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating'], true);


function Memorize(fs) {
  var fieldList = Schema(fs)['fields'];
  Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
  var temp_dict = {
    fields: fieldList,
    geometryType: '',
    features: []
  }

    for (var f in fs) {
    var attrs = {}
    for (var attr in f) {
      attrs[attr] = f[attr]
    }
    attrs['collision_year'] = Year(f['date'])
    Push(
      temp_dict['features'],
      {attributes: attrs}
    )
  }

return FeatureSet(temp_dict);
}

var newFS = Memorize(crashFs)
var summaryFS = GroupBy(newFS, 'collision_year',
  [
    {name: 'Total Deaths', expression: 'number_dead', statistic: 'SUM' }, 
    {name: 'Total Injuries', expression: 'gis_incapacitating', statistic: 'SUM' }  ]);

return summaryFS;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Jun 2024 15:30:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495410#M9836</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-20T15:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495414#M9837</link>
      <description>&lt;P&gt;Thanks Ken for taking another look, received this error:&amp;nbsp;&lt;SPAN&gt;Test execution error: Execution error - Key not found - date. Verify test data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I don't see in the expression where collision_date (the date field) is referenced, maybe I'm missing something?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 15:35:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495414#M9837</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-20T15:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495425#M9838</link>
      <description>&lt;P&gt;Two more changes. Line 8 should be&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating', 'collision_date'], true);&lt;/LI-CODE&gt;&lt;P&gt;and line 25 should&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;attrs['collision_year'] = Year(f['collision_date'])&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Jun 2024 15:41:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495425#M9838</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-20T15:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression in Dashboard runs in testing, then Unable to execute Arcade script appears</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495435#M9839</link>
      <description>&lt;P&gt;Really close Ken, output is not counting the injuries though, looks like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardCreek_0-1718898744142.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/107533i345EF2F10BDBF81A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RichardCreek_0-1718898744142.png" alt="RichardCreek_0-1718898744142.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;gis_incapacitating is a string field (Yes or No) and needs to be counted for 'Yes' records and then summed&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current expression iteration for reference:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// sets portal url
var cobportal = Portal('https://bloomingtonin.maps.arcgis.com/');

// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;

// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating', 'collision_date'], true);


function Memorize(fs) {
  var fieldList = Schema(fs)['fields'];
  Push(fieldList, {"alias":"Collision Year","editable":true,"length":4,"name":"collision_year","nullable":true,"type":"esriFieldTypeInteger"})
  var temp_dict = {
    fields: fieldList,
    geometryType: '',
    features: []
  }

    for (var f in fs) {
    var attrs = {}
    for (var attr in f) {
      attrs[attr] = f[attr]
    }
    attrs['collision_year'] = Year(f['collision_date'])
    Push(
      temp_dict['features'],
      {attributes: attrs}
    )
  }

return FeatureSet(temp_dict);
}

var newFS = Memorize(crashFs)
var summaryFS = GroupBy(newFS, 'collision_year',
  [
    {name: 'Total Deaths', expression: 'number_dead', statistic: 'SUM' }, 
    {name: 'Total Injuries', expression: 'gis_incapacitating', statistic: 'SUM' }  ]);

return summaryFS;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Jun 2024 15:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-expression-in-dashboard-runs-in-testing/m-p/1495435#M9839</guid>
      <dc:creator>RichardCreek</dc:creator>
      <dc:date>2024-06-20T15:54:42Z</dc:date>
    </item>
  </channel>
</rss>

