<?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 Help with Data Expression to Sumarize Spatial Joined Features in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/help-with-data-expression-to-sumarize-spatial/m-p/1570311#M10600</link>
    <description>&lt;P&gt;I'm trying to write an Arcade data expression to calculate summary statistics for a line layer of pipes, grouped by a polygon layer of sewersheds, but I'm struggling. Goal output would be the following table:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Sewershed&lt;/TD&gt;&lt;TD width="50%"&gt;Length of all pipe features&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;A&lt;/TD&gt;&lt;TD width="50%"&gt;10,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;B&lt;/TD&gt;&lt;TD width="50%"&gt;9,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;11,000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code that I've got so far, but I'm struggling to figure out how to get the sum of all pipe lengths, per intersecting feature (sewershed).&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Get sewersheds.
var sdata = FeatureSetByPortalItem(Portal('portalURL'), 'sewershedLayerID', 13);

// Get pipes.
var pdata = FeatureSetByPortalItem(Portal('portalURL'), 'pipeLayerID', 11);

// List all sewersheds
var sheds = Distinct(sdata, "sewershed"); // List of sewersheds.

// This line successfully returns what I want by the pipe type, but there's no intersection happening here. Instead of pipe type, I want the intersecting sewershed as the groupby category, and that's why I'm attempting this data expression instead of just bringing the layer into the dashboard.
return GroupBy(pdata, ['type'], {name: 'Total Pipe Length', expression: 'Shape__Length', statistic: 'sum'});

// Iterate each pipe and get the sewershed, but this isn't working and seems really inefficient anyway given that I have many thousands of pipes.
for (pipe in pdata) {
    var y = First(Intersects($feature, sdata));
    if (y == null) return;
}​&lt;/LI-CODE&gt;&lt;P&gt;I'm hoping to extrapolate the solution here to additional datasets. For example, I'll need to create the number of properties served in each sewershed, and similar for other datasets.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Dec 2024 19:26:06 GMT</pubDate>
    <dc:creator>Adam_blaine</dc:creator>
    <dc:date>2024-12-19T19:26:06Z</dc:date>
    <item>
      <title>Help with Data Expression to Sumarize Spatial Joined Features</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/help-with-data-expression-to-sumarize-spatial/m-p/1570311#M10600</link>
      <description>&lt;P&gt;I'm trying to write an Arcade data expression to calculate summary statistics for a line layer of pipes, grouped by a polygon layer of sewersheds, but I'm struggling. Goal output would be the following table:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Sewershed&lt;/TD&gt;&lt;TD width="50%"&gt;Length of all pipe features&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;A&lt;/TD&gt;&lt;TD width="50%"&gt;10,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;B&lt;/TD&gt;&lt;TD width="50%"&gt;9,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;11,000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code that I've got so far, but I'm struggling to figure out how to get the sum of all pipe lengths, per intersecting feature (sewershed).&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Get sewersheds.
var sdata = FeatureSetByPortalItem(Portal('portalURL'), 'sewershedLayerID', 13);

// Get pipes.
var pdata = FeatureSetByPortalItem(Portal('portalURL'), 'pipeLayerID', 11);

// List all sewersheds
var sheds = Distinct(sdata, "sewershed"); // List of sewersheds.

// This line successfully returns what I want by the pipe type, but there's no intersection happening here. Instead of pipe type, I want the intersecting sewershed as the groupby category, and that's why I'm attempting this data expression instead of just bringing the layer into the dashboard.
return GroupBy(pdata, ['type'], {name: 'Total Pipe Length', expression: 'Shape__Length', statistic: 'sum'});

// Iterate each pipe and get the sewershed, but this isn't working and seems really inefficient anyway given that I have many thousands of pipes.
for (pipe in pdata) {
    var y = First(Intersects($feature, sdata));
    if (y == null) return;
}​&lt;/LI-CODE&gt;&lt;P&gt;I'm hoping to extrapolate the solution here to additional datasets. For example, I'll need to create the number of properties served in each sewershed, and similar for other datasets.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2024 19:26:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/help-with-data-expression-to-sumarize-spatial/m-p/1570311#M10600</guid>
      <dc:creator>Adam_blaine</dc:creator>
      <dc:date>2024-12-19T19:26:06Z</dc:date>
    </item>
  </channel>
</rss>

