<?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 Arcade in dashboard challenges in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-in-dashboard-challenges/m-p/1124279#M43269</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a polygon layer (my city's districts) and a point layer (new trees planted in my city). The tree points are crowd-sourced from a survey 123, it is therefore a shared update layer with sync enabled.&lt;/P&gt;&lt;P&gt;I want to display how many tree points are planted per district in a dashboard, perhaps in a list. For instance:&lt;BR /&gt;District A: 35 new trees&lt;BR /&gt;District B: 2 new trees&lt;/P&gt;&lt;P&gt;How can I connect the district polygon layer and the tree point layer in dashboard?&lt;/P&gt;&lt;P&gt;Here is what I have attempted so far:&lt;/P&gt;&lt;P&gt;In map viewer I have successfully done this using arcade in popup for the district polygon layer:&lt;/P&gt;&lt;PRE&gt;var treepoints= FeatureSetByName($map, "new_tree_points")&lt;BR /&gt;var numberoftrees= Count(Contains(treepoints,$feature))&lt;BR /&gt;return numberoftrees&lt;/PRE&gt;&lt;P&gt;This expression does not function in dashboard because I cannot figure out how to refer to another layer than the one I have selected. I have understood that the arcade profiles are different for map viewer and dashboard. In both dashboard List settings and Data expressions I have tried&amp;nbsp;FeatureSetByPortalItem, but I get error message "&lt;SPAN class=""&gt;Parse Error:&lt;/SPAN&gt;&lt;SPAN&gt;featuresetbyportalitem is not available". My AGOL organization has not yet implemented Portal, is this the reason I cannot refer to a portal item?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have also tried to calculate a field with this value and just show the new field in the dashboard list, but I have the same challenge with figuring out how to refer to another layer/feature. I also understand that Arcade cannot be used on hosted features with sync enabled so this may not be the way to go. Any pointers are appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Dec 2021 13:10:09 GMT</pubDate>
    <dc:creator>Sil_</dc:creator>
    <dc:date>2021-12-09T13:10:09Z</dc:date>
    <item>
      <title>Arcade in dashboard challenges</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-in-dashboard-challenges/m-p/1124279#M43269</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a polygon layer (my city's districts) and a point layer (new trees planted in my city). The tree points are crowd-sourced from a survey 123, it is therefore a shared update layer with sync enabled.&lt;/P&gt;&lt;P&gt;I want to display how many tree points are planted per district in a dashboard, perhaps in a list. For instance:&lt;BR /&gt;District A: 35 new trees&lt;BR /&gt;District B: 2 new trees&lt;/P&gt;&lt;P&gt;How can I connect the district polygon layer and the tree point layer in dashboard?&lt;/P&gt;&lt;P&gt;Here is what I have attempted so far:&lt;/P&gt;&lt;P&gt;In map viewer I have successfully done this using arcade in popup for the district polygon layer:&lt;/P&gt;&lt;PRE&gt;var treepoints= FeatureSetByName($map, "new_tree_points")&lt;BR /&gt;var numberoftrees= Count(Contains(treepoints,$feature))&lt;BR /&gt;return numberoftrees&lt;/PRE&gt;&lt;P&gt;This expression does not function in dashboard because I cannot figure out how to refer to another layer than the one I have selected. I have understood that the arcade profiles are different for map viewer and dashboard. In both dashboard List settings and Data expressions I have tried&amp;nbsp;FeatureSetByPortalItem, but I get error message "&lt;SPAN class=""&gt;Parse Error:&lt;/SPAN&gt;&lt;SPAN&gt;featuresetbyportalitem is not available". My AGOL organization has not yet implemented Portal, is this the reason I cannot refer to a portal item?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have also tried to calculate a field with this value and just show the new field in the dashboard list, but I have the same challenge with figuring out how to refer to another layer/feature. I also understand that Arcade cannot be used on hosted features with sync enabled so this may not be the way to go. Any pointers are appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 13:10:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-in-dashboard-challenges/m-p/1124279#M43269</guid>
      <dc:creator>Sil_</dc:creator>
      <dc:date>2021-12-09T13:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade in dashboard challenges</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-in-dashboard-challenges/m-p/1124373#M43272</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var treepoints= FeatureSetByName($map, "new_tree_points")
var numberoftrees= Count(Contains($feature,treepoints))
return numberoftrees&lt;/LI-CODE&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;</description>
      <pubDate>Thu, 09 Dec 2021 15:54:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-in-dashboard-challenges/m-p/1124373#M43272</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2021-12-09T15:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade in dashboard challenges</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-in-dashboard-challenges/m-p/1124404#M43274</link>
      <description>&lt;P&gt;It really depends on &lt;EM&gt;where &lt;/EM&gt;in the Dashboard you're using Arcade, and what exactly you're trying to do with it. If all you want is a list with a count in it, that's not terribly difficult, but accessing other layers in a Dashboard Arcade profile does require a bit more work than usual.&lt;/P&gt;&lt;P&gt;This example should give you a good idea:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Portal
var portal = Portal('https://www.arcgis.com/');

// Create FeatureSet for polygons
var poly_fs = FeatureSetByPortalItem(
    portal,
    '312cebfea2624e108e234220b04460b8',
    0,
    [
        'ZONE'
    ],
    true
);

// Create Featureset for points
var pt_fs = FeatureSetByPortalItem(
    portal,
    '848d61af726f40d890219042253bedd7',
    0,
    [
        'capacity_mw'
    ],
    true
);

// Create empty feature array for output
var features = [];

// Iterate over time zones
for (var poly in poly_fs) {
    
    // Filter points by polygon
    var pts = Contains(poly, pt_fs);
    
    // Create feature with aggregated values
    var feat = { 
        'attributes': { 
            'tz': poly['ZONE'], 
            'pt_cnt': Count(pts)
        }
    };
    
    // Push feature into array
    Push(features, feat);
};

// Create dict for output FeatureSet
var out_dict = { 
    'fields': [
        {'name': 'tz', 'alias': 'Time Zone', 'type': 'esriFieldTypeFloat'},
        {'name': 'pt_cnt', 'alias': 'Number of Power Plants', 'type': 'esriFieldTypeInteger'}
    ],
  'geometryType': '', 
  'features': features 
}; 

// Convert dictionary to feature set. 
return FeatureSet(Text(out_dict)); &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1639066355281.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29287i0EBD15901FD7F44A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1639066355281.png" alt="jcarlson_0-1639066355281.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 16:16:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-in-dashboard-challenges/m-p/1124404#M43274</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-12-09T16:16:22Z</dc:date>
    </item>
  </channel>
</rss>

