HOW TO
In ArcGIS Dashboards, serial chart elements currently do not support aggregating date values by week as a date resolution. However, a data expression can be used to create a new text field that assigns each date to the start date of its corresponding week. This is useful when temporal analysis focuses on weekly patterns rather than individual dates. Grouping date values by week reduces clutter and makes trends easier to identify over time.
Browse this article for the workflow to group date values by week in the ArcGIS Dashboards serial chart elements, and in this example, a column chart is configured to display total sales grouped by week for each city.
// Write an expression that returns a FeatureSet.
// Documentation: https://arcg.is/3c419TD
// Samples: https://arcg.is/HPbi00
// Add portal/layer info
var fs = FeatureSetByPortalItem(
Portal('<PortalURL>'), // Replace <PortalURL> with URL of the portal
'<ItemID>', // Replace <ItemID> with the layer ID
[<LayerIndex>], // Replace <LayerIndex> with the layer index
['<Label1>', '<Label2>', '<dateLabel>'], // Replace <Label1>, <Label2>, and <dateLabel> with the preferred label name
false
);
// Create columns for each of your fields
var newDict = {
fields: [
{ name: "<fieldName1>", type: "esriFieldTypeString" },
{ name: "<fieldName2>", type: "esriFieldTypeInteger" },
{ name: "<dateField>", type: "esriFieldTypeDate" },
{ name: "<fieldName3>", type: "esriFieldTypeString" }
],
'geometryType': '',
"spatialReference": {},
'features': []
};
// loop through each feature in the layer and populate columns
var i = 0;
for (var f in fs) {
var edate = f['<dateLabel>']
var ws = Text(DateAdd(edate, -Weekday(edate), 'days'), "YMMDD")
newDict.features[i++]={
attributes:{
<fieldName1>: f['<Label1>'],
<fieldName2>: f['<Label2>'],
<dateField>: f['<dateLabel>'],
<fieldName3>: ws
}
}
}
return FeatureSet(newDict)
Below is the complete working script for this example.
// Write an expression that returns a FeatureSet.
// Documentation: https://arcg.is/3c419TD
// Samples: https://arcg.is/HPbi00
// Add portal/layer info
var fs = FeatureSetByPortalItem(
Portal('https://www.arcgis.com'),
'e63814c9b04a4ghb84362ba8274ed5a5',
[1],
['cityName', 'totalSales', 'salesDate'],
false
);
// Create columns for each of your fields
var newDict = {
fields: [
{ name: "CityName", type: "esriFieldTypeString" },
{ name: "TotalSales", type: "esriFieldTypeInteger" },
{ name: "SalesDate", type: "esriFieldTypeDate" },
{ name: "NewField", type: "esriFieldTypeString" }
],
'geometryType': '',
"spatialReference": {},
'features': []
};
// loop through each feature in the layer and populate columns
var i = 0;
for (var f in fs) {
var edate = f['salesDate']
var ws = Text(DateAdd(edate, -Weekday(edate), 'days'), "YMMDD")
newDict.features[i++]={
attributes:{
CityName: f['cityName'],
TotalSales: f['totalSales'],
SalesDate: f['salesDate'],
NewField: ws
}
}
}
return FeatureSet(newDict)


Note: Optionally, create a stacked column chart to split the values into groups by selecting the preferred field name from the Split by field drop-down list on the Data tab and selecting Stacked on the Series tab of the Serial chart window. Refer to How To: Create a stacked chart in ArcGIS Dashboards for instructions.
The dashboard below displays weekly total sales for each city in the column chart.

Article ID: 000043116
Get help from ArcGIS experts
Start chatting now