Select to view content in your preferred language

Create Serial chart using a value calculated from two fields that honour filters applied

135
0
2 weeks ago
Labels (1)
MOrfanos_wgaz
New Contributor

Hi All,

I am trying to create a serial chart to display parking occupancy % grouped by time. I have two fields that the calculation needs to be based on, parking capacity and parking occupancy. There are also other additional fields not required for the calc that need to be included so that the chart can be linked by actions to the selectors within the dashboard. The calculation needs to be the sum of all records for capacity / the sum of all records for occupancy *100 for the given records remaining after the selectors have been applied, not just the sum of each value for each record.

I can get the below to run in the "data expression" area and it provides a single value which is what i want as there will be a single % value for each time in the data however I can't seem to use this as it has an error when trying to select the data expression saying unable to execute arcade script. I assume it needs a value in each record to plot this information on a serial chart? if so can anyone think of a way to achieve this?

Any help is much appreciated, Thanks!!!

var portal = Portal('https://xyzxyzxy.arcgis.com');
var itemID = '19ccd5bc5c8a09a01523b8';

 
var featureSet = FeatureSetByPortalItem(
    portal,
    itemID,
    0,
    ['Time', 'Occupancy', 'Capacity_1', 'Site', 'Restriction', 'Street', 'Zone', 'Data_Type', 'Area'], // Included all fields
    false
);

 
if (IsEmpty(featureSet)) {
    return "FeatureSet is empty or invalid. Check the itemID or sublayer ID.";
}

 
var result = Round((Sum(featureSet, "Occupancy") / Sum(featureSet, "Capacity_1")) * 100, 2);

return result;
0 Kudos
0 Replies