Hello - I am using Dashboard to present some metrics from a map. The data set features buildings with data such as the campus they're in, the electric usage and floor area. One of the metrics I want to display is aggregated average electricity use at campus area (i.e. sum up the total electrical usage over features within a campus and divide by the area footprint of buildings in the same campus). I've been trying to use data expressions to do this but have been struggling as I haven't used Arcade much, was hoping someone could help.
So far I've used the GroupBy (see below) to see a table of aggregated values by campus, but I'm not sure how to then add a field and caluclate the use by square meter.
Don't think this is the best method regardless as ideally the filter on the dashboard will select the campus and the expression will just return (sum of all selected electricity use) / (sum of selected area).
var portal = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(
portal,
'14635dbc307947efa58a1b363feb43a5');
var CampusAgg = GroupBy(fs,['Campus_1'],[
{name:'Campus_Floor_Area', expression:'Floor_Area', statistic: 'SUM'},
{name:'Campus_Electricity_kWh', expression:'Electricity_kWh', statistic: 'SUM'},
]);
return CampusAgg;