Hello All,
I'm trying to make a simple algebraic calculation based on multiple fields from the same data layer, specifically, to divide one field by another. A hitch, perhaps, is that I need the input to this calculation to be filterable by multiple selectors from within the Dashboard, i.e. month, year, and/or location, so I don't want to group by any of these options. I need the resulting info to be used in both an indicator and in multiple charts.
I saw something similar on GitHub, https://github.com/Esri/arcade-expressions/blob/master/dashboard/dashboard_data/CalculationAcrossFields.md , and mimicked that...but it doesn't work (and I don't quite understand Dictionaries, either, I have to admit). I get "Test execution error: Execution error - Invalid parameter. Verify test data."
Any thoughts would be greatly appreciated. Thank you!
//Divide two fields from the same layer
//Result must be filterable by multiple selectors within the Dashboard
var portal = Portal('https://arcgis.com');
var fs = FeatureSetByPortalItem(
portal,
'86ba934a1b4c4ff2ae8188a012256ffc',
0,
[
'TotalSteelhead',
'TotalTrips'
],
false
);
var ratioDict = {
'fields': {'name': 'CPUE', 'type': 'esriFieldTypeDouble'},
'features':
[{'attributes':
{'CPUE': Round((SUM(fs,'TotalSteelhead')/SUM(fs,'TotalTrips')),2)}
}]};
return FeatureSet(ratioDict)