<?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 Append tables in data expression in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/append-tables-in-data-expression/m-p/1228836#M6964</link>
    <description>&lt;P&gt;I am new to using Arcade expressions. I want a dashboard to aggregate data from 4 different feature layers into a table or a chart. The data has four maps with polyline feature layer representing each year 2023, 2026, 2036 and 2045. I was able to create aggregated data from individual layers by repeating the following code for each layer's data source.&amp;nbsp;&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(Portal('&lt;A href="https://tamu.maps.arcgis.com" target="_blank"&gt;https://tamu.maps.arcgis.com&lt;/A&gt;'), '302880accba645198a5174df9f51b300', 3,['STREET','FAC_TYPE','NUM_LANES','MTP_ID'])&lt;BR /&gt;var agg = GroupBy(fs,['MTP_ID','FAC_TYPE','STREET'],[{name:'Lanes',expression:'NUM_LANES',statistic: 'MAX'}])&lt;BR /&gt;var agsum = GroupBy(agg,['MTP_ID','FAC_TYPE'],[{name:'Lanes',expression:'Lanes',statistic:'SUM'}])&lt;BR /&gt;return agsum&lt;/P&gt;&lt;P&gt;Ideally I want them in a single table which shows the number of lanes in each year for each MTP ID.&amp;nbsp; I am not sure which function to use to append&amp;nbsp; tables with arcade expressions.&amp;nbsp; Any help would be appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 17:21:49 GMT</pubDate>
    <dc:creator>RohitJaikumar</dc:creator>
    <dc:date>2022-11-04T17:21:49Z</dc:date>
    <item>
      <title>Append tables in data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/append-tables-in-data-expression/m-p/1228836#M6964</link>
      <description>&lt;P&gt;I am new to using Arcade expressions. I want a dashboard to aggregate data from 4 different feature layers into a table or a chart. The data has four maps with polyline feature layer representing each year 2023, 2026, 2036 and 2045. I was able to create aggregated data from individual layers by repeating the following code for each layer's data source.&amp;nbsp;&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(Portal('&lt;A href="https://tamu.maps.arcgis.com" target="_blank"&gt;https://tamu.maps.arcgis.com&lt;/A&gt;'), '302880accba645198a5174df9f51b300', 3,['STREET','FAC_TYPE','NUM_LANES','MTP_ID'])&lt;BR /&gt;var agg = GroupBy(fs,['MTP_ID','FAC_TYPE','STREET'],[{name:'Lanes',expression:'NUM_LANES',statistic: 'MAX'}])&lt;BR /&gt;var agsum = GroupBy(agg,['MTP_ID','FAC_TYPE'],[{name:'Lanes',expression:'Lanes',statistic:'SUM'}])&lt;BR /&gt;return agsum&lt;/P&gt;&lt;P&gt;Ideally I want them in a single table which shows the number of lanes in each year for each MTP ID.&amp;nbsp; I am not sure which function to use to append&amp;nbsp; tables with arcade expressions.&amp;nbsp; Any help would be appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 17:21:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/append-tables-in-data-expression/m-p/1228836#M6964</guid>
      <dc:creator>RohitJaikumar</dc:creator>
      <dc:date>2022-11-04T17:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Append tables in data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/append-tables-in-data-expression/m-p/1228846#M6965</link>
      <description>&lt;P&gt;If all you need is to merge your tables together, you'll need to use loops and push the features into a single array. There's currently no easier way to get the features from one set out into an array, unfortunately.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var merge_arr = []

// repeat this loop for each of your grouped featuresets
for (var f in fs){
    Push(merge_arr, f)
}

// this assumes your schemas are all the same between layers
var merge_dict = {
    fields: Schema(fs)['fields'],
    geometryType: '',
    features: merge_arr
}

var merge_fs = FeatureSet(Text(merge_dict))

return merge_fs&lt;/LI-CODE&gt;&lt;P&gt;There are probably some adjustments you'll need to make to this for your particular data, but this should give you the general idea.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 17:57:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/append-tables-in-data-expression/m-p/1228846#M6965</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-11-04T17:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Append tables in data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/append-tables-in-data-expression/m-p/1228883#M6966</link>
      <description>&lt;P&gt;Thanks for the reply. I think the solution almost works. I think I have no idea how to repeat the for loop to add rows to the merge_arr. It only returns values for 2045 as that's the last loop. Here's what I have&amp;nbsp;&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(Portal('&lt;A href="https://tamu.maps.arcgis.com" target="_blank"&gt;https://tamu.maps.arcgis.com&lt;/A&gt;'), '302880accba645198a5174df9f51b300', 3,['FY','STREET','FAC_TYPE','NUM_LANES','MTP_ID'])&lt;BR /&gt;var fs26 = FeatureSetByPortalItem(Portal('&lt;A href="https://tamu.maps.arcgis.com" target="_blank"&gt;https://tamu.maps.arcgis.com&lt;/A&gt;'), '302880accba645198a5174df9f51b300', 2,['FY','STREET','FAC_TYPE','NUM_LANES','MTP_ID'])&lt;BR /&gt;var fs36 = FeatureSetByPortalItem(Portal('&lt;A href="https://tamu.maps.arcgis.com" target="_blank"&gt;https://tamu.maps.arcgis.com&lt;/A&gt;'), '302880accba645198a5174df9f51b300', 1,['FY','STREET','FAC_TYPE','NUM_LANES','MTP_ID'])&lt;BR /&gt;var fs45 = FeatureSetByPortalItem(Portal('&lt;A href="https://tamu.maps.arcgis.com" target="_blank"&gt;https://tamu.maps.arcgis.com&lt;/A&gt;'), '302880accba645198a5174df9f51b300', 0,['FY','STREET','FAC_TYPE','NUM_LANES','MTP_ID'])&lt;BR /&gt;var merge_arr = []&lt;/P&gt;&lt;P&gt;// repeat this loop for each of your grouped featuresets&lt;BR /&gt;for (var f in fs){&lt;BR /&gt;Push(merge_arr, f)&lt;BR /&gt;}&lt;BR /&gt;for (var f26 in fs26){&lt;BR /&gt;Push(merge_arr, f26)&lt;BR /&gt;}&lt;BR /&gt;for (var f36 in fs36){&lt;BR /&gt;Push(merge_arr, f36)&lt;BR /&gt;}&lt;BR /&gt;for (var f45 in fs45){&lt;BR /&gt;Push(merge_arr, f45)&lt;BR /&gt;}&lt;BR /&gt;// this assumes your schemas are all the same between layers&lt;BR /&gt;var merge_dict = {&lt;BR /&gt;fields: Schema(fs)['fields'],&lt;BR /&gt;geometryType: '',&lt;BR /&gt;features: merge_arr&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var merge_fs = FeatureSet(Text(merge_dict))&lt;/P&gt;&lt;P&gt;var agg = GroupBy(merge_fs,['FY','MTP_ID','FAC_TYPE','STREET'],[{name:'Lanes',expression:'NUM_LANES',statistic: 'MAX'}])&lt;BR /&gt;var agsum = GroupBy(agg,['FY','MTP_ID','FAC_TYPE'],[{name:'Lanes',expression:'Lanes',statistic:'SUM'}])&lt;BR /&gt;return agsum&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 20:13:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/append-tables-in-data-expression/m-p/1228883#M6966</guid>
      <dc:creator>RohitJaikumar</dc:creator>
      <dc:date>2022-11-04T20:13:43Z</dc:date>
    </item>
  </channel>
</rss>

