<?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 Data Expression - &amp;quot;Unable to execute script&amp;quot; in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262628#M7419</link>
    <description>&lt;P&gt;Yes, that's definitely possible! It can take a bit longer, since the only way to merge two featuresets is to do it feature by feature, but it shouldn't be too bad.&lt;/P&gt;&lt;P&gt;Here is an example expression that does just that:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/CombineMultipleLayers(SerialChart).md" target="_blank"&gt;https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/CombineMultipleLayers(SerialChart).md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Never mind that it's for a Serial Chart, you can use the same thing for an indicator.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2023 18:15:00 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2023-02-28T18:15:00Z</dc:date>
    <item>
      <title>Arcade Data Expression - "Unable to execute script"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262469#M7414</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am new to using arcade in dashboards and, hopefully, am making a simple mistake. I am trying to create an indicator from 2 different services (sum of Approved Dwelling Units). I am returning the correct value in the "Edit data expression" page but when I click done I am unable to use the expression - Esri says "Unable to execute script".&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what my code currently looks like. This is my first time calculating values with different layers using FeatureSetByPortalItem&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var PrelimPlans = FeatureSetByPortalItem(&lt;/P&gt;&lt;P&gt;&amp;nbsp; Portal('&lt;A title="https://www.arcgis.com/%27" href="https://www.arcgis.com/%27" target="_blank" rel="noreferrer noopener"&gt;https://www.arcgis.com/'),&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; '2a7c6c6f86b14253b1ecf079e3f4e6dd',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp; ['Name', 'APPR_DU_TOT', 'Count'],&lt;/P&gt;&lt;P&gt;&amp;nbsp; false&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;//Count(PrelimPlans);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var PrelimDUTOT = Sum(PrelimPlans,'APPR_DU_TOT');&lt;/P&gt;&lt;P&gt;//Return PrelimDUTOT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var SitePlan = FeatureSetByPortalItem(&lt;/P&gt;&lt;P&gt;&amp;nbsp; Portal('&lt;A title="https://www.arcgis.com/%27" href="https://www.arcgis.com/%27" target="_blank" rel="noreferrer noopener"&gt;https://www.arcgis.com/'),&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; '33c2a66277c34153907ba5d14484a24b',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 3,&lt;/P&gt;&lt;P&gt;&amp;nbsp; ['Name', 'APPR_DU_TOT', 'Count'],&lt;/P&gt;&lt;P&gt;&amp;nbsp; false&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;//Count(SitePlan);&lt;/P&gt;&lt;P&gt;Sum(SitePlan,"APPR_DU_TOT")&lt;/P&gt;&lt;P&gt;var SitePlanDUTOT = Sum(SitePlan,'APPR_DU_TOT');&lt;/P&gt;&lt;P&gt;//Return SitePlanDUTOT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var CombinedDwellingUnits = PrelimDUTOT + SitePlanDUTOT;&lt;/P&gt;&lt;P&gt;Return CombinedDwellingUnits&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Colin&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 15:05:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262469#M7414</guid>
      <dc:creator>C_McNamara</dc:creator>
      <dc:date>2023-02-28T15:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expression - "Unable to execute script"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262505#M7415</link>
      <description>&lt;P&gt;A Data Expression needs to return a &lt;STRONG&gt;FeatureSet&lt;/STRONG&gt;, where your expression is just returning a number.&lt;/P&gt;&lt;P&gt;The simplest way to do this would be to wrap your number in a single-feature FeatureSet, like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return FeatureSet(Text({
    fields: [{name: 'the_count', type: 'esriFieldTypeInteger'}],
    geometryType: '',
    features: [{attributes: {the_count: CombinedDwellingUnits}}]
}))&lt;/LI-CODE&gt;&lt;P&gt;Put that in instead of your final &lt;STRONG&gt;return &lt;/STRONG&gt;line, see if it works.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 15:59:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262505#M7415</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-02-28T15:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expression - "Unable to execute script"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262513#M7416</link>
      <description>&lt;P&gt;Works!&lt;/P&gt;&lt;P&gt;Thanks, Josh!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 16:17:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262513#M7416</guid>
      <dc:creator>C_McNamara</dc:creator>
      <dc:date>2023-02-28T16:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expression - "Unable to execute script"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262616#M7418</link>
      <description>&lt;P&gt;Hey Josh (&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;),&lt;/P&gt;&lt;P&gt;Is it possible to combine these two layers together by creating a dynamic FeatureSet with a whole bunch of similar variables to visualize summarized stats like the problem above?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="C_McNamara_1-1677606861871.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63918iCCE9E4858C82D490/image-size/medium?v=v2&amp;amp;px=400" role="button" title="C_McNamara_1-1677606861871.png" alt="C_McNamara_1-1677606861871.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, instead of creating a sum in the data expression, I would access a combined table or FeatureSet with 9,669 records (sum/join of my Preliminary plans and Site Plans).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 18:00:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262616#M7418</guid>
      <dc:creator>C_McNamara</dc:creator>
      <dc:date>2023-02-28T18:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expression - "Unable to execute script"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262628#M7419</link>
      <description>&lt;P&gt;Yes, that's definitely possible! It can take a bit longer, since the only way to merge two featuresets is to do it feature by feature, but it shouldn't be too bad.&lt;/P&gt;&lt;P&gt;Here is an example expression that does just that:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/CombineMultipleLayers(SerialChart).md" target="_blank"&gt;https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/CombineMultipleLayers(SerialChart).md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Never mind that it's for a Serial Chart, you can use the same thing for an indicator.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 18:15:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262628#M7419</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-02-28T18:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Data Expression - "Unable to execute script"</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262635#M7420</link>
      <description>&lt;P&gt;Think I got it!!&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var PrelimPlans = FeatureSetByPortalItem(Portal('https://www.arcgis.com/'),'2a7c6c6f86b14253b1ecf079e3f4e6dd',1,['*'],false);
var SitePlan = FeatureSetByPortalItem(Portal('https://www.arcgis.com/'),'33c2a66277c34153907ba5d14484a24b',3,['*'],false); 
//var SitePlanDUTOT = Sum(SitePlan,'APPR_DU_TOT');
//Return SitePlanDUTOT
//Distinct(SitePlan,'APNO') var combinedDict = { 
  'fields': [ 
    { name: "APNO", type:"esriFieldTypeString" },
    { name: "APPR_DU_TOT", type: "esriFieldTypeDouble" },
    { name: "PROP_DU_SF", type: "esriFieldTypeDouble" }, 
    { name: "PROP_DU_MF", type: "esriFieldTypeDouble" },
    {name: "APPR_SQFT_TOT", type: "esriFieldTypeDouble" },
  ], 
  geometryType: "", 
  features: [], 
}; var i = 0; 
// Loop through each FeatureSet and store its attributes 
for (var t in PrelimPlans) { 
  combinedDict.features[i++] = { 
    attributes: {
      APNO: t["APNO"],
      APPR_DU_TOT: t["APPR_DU_TOT"],
      PROP_DU_SF: t["PROP_DU_SF"], 
      PROP_DU_MF: t["PROP_DU_MF"],
      APPR_SQFT_TOT: t["APPR_SQFT_TOT"],
    }, 
  }; 
} for (var m in SitePlan) { 
  combinedDict.features[i++] = { 
    attributes: { 
      APNO: m["APNO"],
      APPR_DU_TOT: m["APPR_DU_TOT"],
      PROP_DU_SF: m["PROP_DU_SF"], 
      PROP_DU_MF: m["PROP_DU_MF"],
      APPR_SQFT_TOT: m["APPR_SQFT_TOT"],
    }, 
  }; 
}
return FeatureSet(Text(combinedDict))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Feb 2023 18:26:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-data-expression-quot-unable-to-execute/m-p/1262635#M7420</guid>
      <dc:creator>C_McNamara</dc:creator>
      <dc:date>2023-02-28T18:26:29Z</dc:date>
    </item>
  </channel>
</rss>

