<?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: Dashboard - Arcade calculation from 2 Layers in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-arcade-calculation-from-2-layers/m-p/1337507#M8573</link>
    <description>&lt;P&gt;Data Expressions have to return a &lt;STRONG&gt;FeatureSet&lt;/STRONG&gt;. If you really just want that single number, you can try this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//***Visitors***//

var OfficeVisitors = FeatureSetByPortalItem (Portal('portalURL'),  'layerID',  0,   ['*'],   false);

var Visitors = Sum(OfficeVisitors, 'visit_cnt');

//***Incident***//

var Incidents = FeatureSetByPortalItem (Portal('portalURL'), 'layerID', 0,  ['*'], false);

var Total_Incidents = Count(Incidents);

//***Incidents 100K Visitors***//

var IncidentsPer100K = (Incidents/Visitors)*100000

var out_dict = {
  fields: [
    {name: 'incidentsPer100K', type: 'esriFieldTypeDouble'}
  ],
  geometryType: '',
  features: [
    { attributes: { incidentsPer100K: IncidentsPer100K }}
  ]
}

return FeatureSet(out_dict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But really, I think you could do this with a &lt;STRONG&gt;reference value&lt;/STRONG&gt; as well.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2023 20:56:26 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2023-10-12T20:56:26Z</dc:date>
    <item>
      <title>Dashboard - Arcade calculation from 2 Layers</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-arcade-calculation-from-2-layers/m-p/1337489#M8571</link>
      <description>&lt;P&gt;Hi, I am trying to create a simple calculation which works in the Arcade Expression, but says its unable to execute within a Dashboard Element (Indicator).&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In Dashboards, I add Element &amp;gt; Indicator &amp;gt; select the 'New Data Expression' enter the code and its valid, but when i click 'Done' i get 'Unable to execute Arcade script'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Arcade_works.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82982i35117FCA77DF8C7E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Arcade_works.PNG" alt="Arcade_works.PNG" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Arcade_works.PNG&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="AIRS_Unabletoexecute.jpg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82981iB663F6952E640F50/image-size/large?v=v2&amp;amp;px=999" role="button" title="AIRS_Unabletoexecute.jpg" alt="AIRS_Unabletoexecute.jpg" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;AIRS_Unabletoexecute.jpg&lt;/span&gt;&lt;/span&gt;&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;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;//***Visitors***//&lt;/P&gt;&lt;P&gt;var OfficeVisitors = FeatureSetByPortalItem (Portal('portalURL'),&amp;nbsp;&amp;nbsp;'layerID',&amp;nbsp; 0,&amp;nbsp;&amp;nbsp; ['*'],&amp;nbsp;&amp;nbsp; false);&lt;/P&gt;&lt;P&gt;var Visitors = Sum(OfficeVisitors, 'visit_cnt');&lt;/P&gt;&lt;P&gt;//***Incident***//&lt;/P&gt;&lt;P&gt;var Incidents = FeatureSetByPortalItem (Portal('portalURL'),&amp;nbsp;'layerID', 0,&amp;nbsp; ['*'], false);&lt;/P&gt;&lt;P&gt;var Total_Incidents = Count(Incidents);&lt;/P&gt;&lt;P&gt;//***Incidents 100K Visitors***//&lt;/P&gt;&lt;P&gt;var IncidentsPer100K = (Incidents/Visitors)*100000&lt;/P&gt;&lt;P&gt;return IncidentsPer100K&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You,&lt;/P&gt;&lt;P&gt;Jack&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 20:26:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-arcade-calculation-from-2-layers/m-p/1337489#M8571</guid>
      <dc:creator>JackG</dc:creator>
      <dc:date>2023-10-12T20:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Arcade calculation from 2 Layers</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-arcade-calculation-from-2-layers/m-p/1337507#M8573</link>
      <description>&lt;P&gt;Data Expressions have to return a &lt;STRONG&gt;FeatureSet&lt;/STRONG&gt;. If you really just want that single number, you can try this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//***Visitors***//

var OfficeVisitors = FeatureSetByPortalItem (Portal('portalURL'),  'layerID',  0,   ['*'],   false);

var Visitors = Sum(OfficeVisitors, 'visit_cnt');

//***Incident***//

var Incidents = FeatureSetByPortalItem (Portal('portalURL'), 'layerID', 0,  ['*'], false);

var Total_Incidents = Count(Incidents);

//***Incidents 100K Visitors***//

var IncidentsPer100K = (Incidents/Visitors)*100000

var out_dict = {
  fields: [
    {name: 'incidentsPer100K', type: 'esriFieldTypeDouble'}
  ],
  geometryType: '',
  features: [
    { attributes: { incidentsPer100K: IncidentsPer100K }}
  ]
}

return FeatureSet(out_dict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But really, I think you could do this with a &lt;STRONG&gt;reference value&lt;/STRONG&gt; as well.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 20:56:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-arcade-calculation-from-2-layers/m-p/1337507#M8573</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-10-12T20:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Arcade calculation from 2 Layers</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-arcade-calculation-from-2-layers/m-p/1337737#M8578</link>
      <description>&lt;P&gt;For the FeatureSet return, you have to use 'text' as well to get results.&amp;nbsp;&amp;nbsp;&amp;nbsp;FeatureSet(Text (out_dict)) worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you or know how i can add a date filter to the portalitem?&amp;nbsp; I want to show visitor counts to say where &lt;EM&gt;'day_dt' &amp;gt;= '01/01/2016'&lt;/EM&gt;&amp;nbsp; I assume I have to add the filter around the SetPortalitem based on a few other posts but can't seem to get it working right.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then ultimately i wanted to somehow display the incidents per 100K visitors for each month somehow... Right now the visitor table i have goes back to 2004 and the incident table is from 2016. So i need to at least filter the visitor counts to "&lt;EM&gt;is or is after" 01/01/2016"&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would somehow like to groupby month somehow of incidents per 100K visitors per month&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;output to be:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{ attributes: 
{ Jan 2016: IncidentsPer100K}
{ Feb 2016: IncidentsPer100K}
{ March 2016: IncidentsPer100K}
{ Apr 2016: IncidentsPer100K}
{etc: etc}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 14:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-arcade-calculation-from-2-layers/m-p/1337737#M8578</guid>
      <dc:creator>JackG</dc:creator>
      <dc:date>2023-10-13T14:18:28Z</dc:date>
    </item>
  </channel>
</rss>

