<?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 Table - Transpose dates into columns in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/table-transpose-dates-into-columns/m-p/1255270#M7309</link>
    <description>&lt;P&gt;I have a &lt;A href="https://www.arcgis.com/home/item.html?id=b8505ee34f414a5a842b0f0a32ea3e94#data" target="_self"&gt;public layer&lt;/A&gt; for Fire Danger Forecasts by district.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Each &lt;STRONG&gt;DIST_NAME&lt;/STRONG&gt; has 4 records for the next 4 days&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;START_DATE&amp;nbsp; &lt;/STRONG&gt;is a date field.&amp;nbsp; This is not constant, and is always today + 3 days for the forecasts&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Each record has a &lt;STRONG&gt;FireDanger&lt;/STRONG&gt; value which is the forecast.&amp;nbsp; e.g. Moderate&lt;/LI&gt;&lt;LI&gt;There is a&amp;nbsp;&lt;STRONG&gt;Forecast_Period &lt;/STRONG&gt;which is 1-4.&amp;nbsp; If I can't work out how to convert the date to the day name, this might be an easier one to work&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_0-1675682091802.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62148iA03B819A038AC85C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_0-1675682091802.png" alt="SimonGIS_0-1675682091802.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to use an advanced expression to split the table out to&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;One District per row&lt;/LI&gt;&lt;LI&gt;Columns for each of the four days.&amp;nbsp;&lt;UL&gt;&lt;LI&gt;dd/mm/yyyy or the actual day. (Monday, Tuesday, etc).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;The Fire Danger Rating in each of these columns for the appropriate days&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Final end goal looking to replicate:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_1-1675682307766.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62149i9D771C38CD5CF116/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_1-1675682307766.png" alt="SimonGIS_1-1675682307766.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have been looking through the posts and samples, but yet to find anything that helps dimension a table in this way.&amp;nbsp; Can someone give me some pointers or similar examples they have seen to get me started?&amp;nbsp; New to Arcade.&lt;BR /&gt;&lt;BR /&gt;I was thinking &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#groupby" target="_blank" rel="noopener"&gt;GroupBy&lt;/A&gt; might be the right approach? But the expression statistic type is geared more to working with numerical data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect I am missing something quite obvious here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(Portal('https://arcgis.com/'), 'b8505ee34f414a5a842b0f0a32ea3e94', 5, ['DIST_NAME', 'FireDanger', 'Start_Time', 'FireBehavIndex'], false);

var features = [];

for (feature in fs) { 
    var feat = {'attributes': { 
            'District': '',
            'Sunday': '',
            'Monday': '',
            'Tuesday': '',
            'Wednesday': ''
        }}
    feat.attributes.District = feature['DIST_NAME'];
    feat.attributes[Text(ToUTC(feature['Start_Time']), 'dddd')] = feature['FireDanger'] + ', ' + feature['FireBehavIndex'];
    Push(features, feat);
};

var fs_dict = {
    'fields': [
        { 'name': 'District', 'type': 'esriFieldTypeString'},
        { 'name': 'Sunday', 'type': 'esriFieldTypeString'},
        { 'name': 'Monday', 'type': 'esriFieldTypeString'},
        { 'name': 'Tuesday', 'type': 'esriFieldTypeString'},
        { 'name': 'Wednesday', 'type': 'esriFieldTypeString'},
    ], 
    'geometryType': '', 
    'features': features
};


var fsDict = FeatureSet(Text(fs_dict)); 

var fs_gp = GroupBy(fsDict, ['District'], 
[{name: 'Sunday', expression: "Sunday", statistic: 'sum' }, 
 {name: 'Monday', expression: 'Monday', statistic: 'sum' },
 {name: 'Tuesday', expression: 'Tuesday', statistic: 'sum' },
 {name: 'Wednesday', expression: 'Wednesday', statistic: 'sum' },
])

return fs_gp&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;Returns:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_0-1675857024085.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62350i4D26E46FE689E3B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_0-1675857024085.png" alt="SimonGIS_0-1675857024085.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Feb 2023 06:53:30 GMT</pubDate>
    <dc:creator>SimonGIS</dc:creator>
    <dc:date>2023-02-13T06:53:30Z</dc:date>
    <item>
      <title>Table - Transpose dates into columns</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/table-transpose-dates-into-columns/m-p/1255270#M7309</link>
      <description>&lt;P&gt;I have a &lt;A href="https://www.arcgis.com/home/item.html?id=b8505ee34f414a5a842b0f0a32ea3e94#data" target="_self"&gt;public layer&lt;/A&gt; for Fire Danger Forecasts by district.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Each &lt;STRONG&gt;DIST_NAME&lt;/STRONG&gt; has 4 records for the next 4 days&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;START_DATE&amp;nbsp; &lt;/STRONG&gt;is a date field.&amp;nbsp; This is not constant, and is always today + 3 days for the forecasts&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Each record has a &lt;STRONG&gt;FireDanger&lt;/STRONG&gt; value which is the forecast.&amp;nbsp; e.g. Moderate&lt;/LI&gt;&lt;LI&gt;There is a&amp;nbsp;&lt;STRONG&gt;Forecast_Period &lt;/STRONG&gt;which is 1-4.&amp;nbsp; If I can't work out how to convert the date to the day name, this might be an easier one to work&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_0-1675682091802.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62148iA03B819A038AC85C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_0-1675682091802.png" alt="SimonGIS_0-1675682091802.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to use an advanced expression to split the table out to&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;One District per row&lt;/LI&gt;&lt;LI&gt;Columns for each of the four days.&amp;nbsp;&lt;UL&gt;&lt;LI&gt;dd/mm/yyyy or the actual day. (Monday, Tuesday, etc).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;The Fire Danger Rating in each of these columns for the appropriate days&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Final end goal looking to replicate:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_1-1675682307766.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62149i9D771C38CD5CF116/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_1-1675682307766.png" alt="SimonGIS_1-1675682307766.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have been looking through the posts and samples, but yet to find anything that helps dimension a table in this way.&amp;nbsp; Can someone give me some pointers or similar examples they have seen to get me started?&amp;nbsp; New to Arcade.&lt;BR /&gt;&lt;BR /&gt;I was thinking &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#groupby" target="_blank" rel="noopener"&gt;GroupBy&lt;/A&gt; might be the right approach? But the expression statistic type is geared more to working with numerical data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect I am missing something quite obvious here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(Portal('https://arcgis.com/'), 'b8505ee34f414a5a842b0f0a32ea3e94', 5, ['DIST_NAME', 'FireDanger', 'Start_Time', 'FireBehavIndex'], false);

var features = [];

for (feature in fs) { 
    var feat = {'attributes': { 
            'District': '',
            'Sunday': '',
            'Monday': '',
            'Tuesday': '',
            'Wednesday': ''
        }}
    feat.attributes.District = feature['DIST_NAME'];
    feat.attributes[Text(ToUTC(feature['Start_Time']), 'dddd')] = feature['FireDanger'] + ', ' + feature['FireBehavIndex'];
    Push(features, feat);
};

var fs_dict = {
    'fields': [
        { 'name': 'District', 'type': 'esriFieldTypeString'},
        { 'name': 'Sunday', 'type': 'esriFieldTypeString'},
        { 'name': 'Monday', 'type': 'esriFieldTypeString'},
        { 'name': 'Tuesday', 'type': 'esriFieldTypeString'},
        { 'name': 'Wednesday', 'type': 'esriFieldTypeString'},
    ], 
    'geometryType': '', 
    'features': features
};


var fsDict = FeatureSet(Text(fs_dict)); 

var fs_gp = GroupBy(fsDict, ['District'], 
[{name: 'Sunday', expression: "Sunday", statistic: 'sum' }, 
 {name: 'Monday', expression: 'Monday', statistic: 'sum' },
 {name: 'Tuesday', expression: 'Tuesday', statistic: 'sum' },
 {name: 'Wednesday', expression: 'Wednesday', statistic: 'sum' },
])

return fs_gp&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;Returns:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SimonGIS_0-1675857024085.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62350i4D26E46FE689E3B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SimonGIS_0-1675857024085.png" alt="SimonGIS_0-1675857024085.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 06:53:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/table-transpose-dates-into-columns/m-p/1255270#M7309</guid>
      <dc:creator>SimonGIS</dc:creator>
      <dc:date>2023-02-13T06:53:30Z</dc:date>
    </item>
  </channel>
</rss>

