I am trying to create an arcade expression to power a serial chart to show days of the week statistic of incidents in city. I used the weekday function to calculate days of the week which returns number from 0 to 6 and also extracted weekday as a string and then loop through the feature set and copy over the extracted values to a dictionary. The written code below has worked accordingly and the result is the table below. The problem is all the values are shifted. I think it's happening because the day of the week start with Sunday. How can I shift the values or change the start of the week from Sunday to Monday so that Monday there is 1400 accidents, Tuesday 1200, Wednesday, 1580 etc.??
dow_num | dow | incidents |
0 | Sunday | 1400 |
1 | Monday | 1200 |
2 | Tuesday | 1580 |
3 | Wednesday | 1500 |
4 | Thursday | 1600 |
5 | Friday | 1111 |
6 | Saturday | 1020 |
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'),
'idofthelayer',
0,
['Dates', 'NumberofIncident'], false
);
var sql = "Dates BETWEEN '01/01/2020' AND '12/31/2020'"
var fs_filt = Filter(fs, sql)
var dowDict = {
'fields':[{
'name': 'dow_num',
'type': 'esriFieldTypeInteger'
},{
'name': 'dow',
'type': 'esriFieldTypeString'
},{
'name': 'incidents',
'type': 'esriFieldTypeInteger'
}],
'geometryType': '',
'features': []
};
var index = 0;
for (var feature in fs_filt) {
dowDict.features[index] = {
'attributes':{
'dow_num':Weekday(feature["Dates"]),
'dow':Text(feature["Dates"],'dddd'),
'collisions': feature["NumberofIncident"]
}
}
index++;
}
var fs_dict = FeatureSet(Text(dowDict))
return GroupBy(fs_dict, ['dow_num','dow'],
[{name: 'incidents_by_Date',
expression: 'incidents', statistic: 'COUNT' } ])