I am trying to display the average event closures in a dashboard list using a GroupBy function. I would like to display the average closures per month and per week. I'm trying to do this using a GroupBy expression that divides the total closed events by the program length. The test results either shows NaN (Not a Number), or no results.
I've tried using the Number function in the expression to convert the equation to a number, but this produces no results in the Test. Apparently can't use a variable in the expression because this again produces no results. I've tried adding fields for Total Weeks and Total Months. This doesn't work either.
I'm fairly new to Arcade . This seems like a simple task. Can some one show me where I'm going wrong?
Thank you
var fs = FeatureSetByPortalItem(Portal('xyz'), 'xyz', 0, ['*'], false);
//Filter for closed events
var fs_closed = Filter(fs, 'STATUS > 1');
//Count rourds after filtering
var cnt = count(fs_closed);
//return cnt
var mths = 5
var wks = 22
// Return a featureset with single group by statistics.
return GroupBy(fs_closed, ['TMM','FUNCTIONAL_ROAD_CLASS','CAMP'],
[
{name: 'Average Reponse Time (hours)', expression: 'RESPONSE_TIME_H/1', statistic: 'AVG'},
{name: 'Average Reponse Time (days)', expression: 'RESPONSE_TIME_H/24', statistic: 'AVG'},
{name: 'Average Reponse Time (weeks)', expression: '(RESPONSE_TIME_H/24)/7', statistic: 'AVG'},
//Count the total records and divide by the program length.
// {name: 'Average Closures Per Week', expression: 'cnt/prglnthwks', statistic: 'AVG'},
{name: 'Average Closures Per Week', expression: 'cnt/wks', statistic: 'MAX'},
//{name: 'Average Closures Per Week', expression: 'Count(OBJECTID)/prglnthwks', statistic: 'AVG'},
//{name: 'Average Closures Per Month', expression: 'cnt/prglnthmths', statistic: 'AVG'}
{name: 'Average Closures Per Month', expression: 'cnt/mths', statistic: 'MAX'}
//{name: 'Average Closures Per Month', expression: 'Count(OBJECTID)/prglnthmths', statistic: 'AVG'}
]
);