<?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: Grouping dates in a serial chart using a data expression in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouping-dates-in-a-serial-chart-using-a-data/m-p/1568404#M10565</link>
    <description>&lt;P&gt;You have an error in your code. The Portal() function is being called twice in line 1 and line 7. The following line (line 7) should not have the Portal() function. It should simply have p as the first parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(p, itemId, layerId, fields, false);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2024 14:04:14 GMT</pubDate>
    <dc:creator>StephenKaranja</dc:creator>
    <dc:date>2024-12-13T14:04:14Z</dc:date>
    <item>
      <title>Grouping dates in a serial chart using a data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouping-dates-in-a-serial-chart-using-a-data/m-p/1200449#M6657</link>
      <description>&lt;P&gt;I have a large table of inspections (a layer in a feature service) that includes a date field ('Inspections_date'; example format: 7/11/2022 2:23:00 PM) and spans several years. I would like to create a serial chart that groups the inspections by month and has two or more series to compare years. A simple excel chart looks like the attached (line chart works too). I know that using a data expression can probably get me there, but 1) I'm fairly new working with Arcade and 2) I can't figure out how to group by the date field to parse out the month. I'm also wondering if I should do some of this work in the feature service (grouping by month) instead of in Dashboard. Any guidance would be much appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="insp_month.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48043i3A4DFF3000F4A907/image-size/medium?v=v2&amp;amp;px=400" role="button" title="insp_month.png" alt="insp_month.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 16:27:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouping-dates-in-a-serial-chart-using-a-data/m-p/1200449#M6657</guid>
      <dc:creator>SWatterson-CALFIRE</dc:creator>
      <dc:date>2022-08-08T16:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping dates in a serial chart using a data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouping-dates-in-a-serial-chart-using-a-data/m-p/1201029#M6659</link>
      <description>&lt;P&gt;Using a similar post/thread I was able to create what I think is pretty close to what I need. However, I'm receiving a "failed to fetch" error when I test it.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;var p = Portal("https://XXX/")

// Get Inspections layer
var itemId = 'xxx'; 
var layerId = 2; 
var fields = ['InspectionDate', 'OBJECTID'];
var fs = FeatureSetByPortalItem(Portal(p), itemId, layerId, fields, false);
//var insp_month = Month(fs);
//var db_month = Decode (insp_month,0,'Jan',1,'Feb',2,'Mar',3,'Apr',4,'May',5,'Jun',6,'Jul',7,'Aug',8,'Sep',9,'Oct',10,'Nov',11,'Dec', 'wrong');

//Create dictionary
var monthDict = { 
  fields: [ 
    {name: 'month_num', type: "esriFieldTypeInteger"},
    {name: 'month_text', type: "esriFieldTypeString"},
    {name: 'insp_count', type: "esriFieldTypeInteger"},
  ], 
  geometryType: "", 
  features: [], 
};

var index = 0; 

// Loop and store attributes 
for (var feature in fs) { 
  monthDict.features[index] = { 
   'attributes': { 
      'month_num':Month(feature['InspectionDate']),
      'month_text': Text(feature['InspectionDate'], 'MMM'),
      'insp_count': feature['OBJECTID'], 
    } 
  } 
  index++;

}
//Get month of inspection
var fs_Dict = FeatureSet(Text(monthDict));   
return GroupBy(fs_Dict, ['month_num', 'month_text'],
[{name: 'insp_by_month', expression: 'inspections', statistic: 'COUNT'}])
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 20:04:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouping-dates-in-a-serial-chart-using-a-data/m-p/1201029#M6659</guid>
      <dc:creator>SWatterson-CALFIRE</dc:creator>
      <dc:date>2022-08-09T20:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping dates in a serial chart using a data expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouping-dates-in-a-serial-chart-using-a-data/m-p/1568404#M10565</link>
      <description>&lt;P&gt;You have an error in your code. The Portal() function is being called twice in line 1 and line 7. The following line (line 7) should not have the Portal() function. It should simply have p as the first parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(p, itemId, layerId, fields, false);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 14:04:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouping-dates-in-a-serial-chart-using-a-data/m-p/1568404#M10565</guid>
      <dc:creator>StephenKaranja</dc:creator>
      <dc:date>2024-12-13T14:04:14Z</dc:date>
    </item>
  </channel>
</rss>

