Hello everyone! I am new to Arcade and hoping someone would be able to help out with this.
I am trying to create a data expression to be used as a data source for a serial chart.
The following appears to work:
var portalsite = Portal('https://arcgis.com');
var fs = FeatureSetByPortalItem(
portalsite,
'6ad1b5d6decd4914a3891953762d241d',
0,
[
'REPORTED_MAGNITUDE',
'MAGNITUDE_TYPE'
],
false
);
return GroupBy(
fs,
['REPORTED_MAGNITUDE',
'MAGNITUDE_TYPE'],
[{name:'Total', expression: '1', statistic:'COUNT'}]
);
However, aside from REPORTED_MAGNITUDE and MAGNITUDE TYPE, I would also like to return a field that uses the following logic:
When( REPORTED_MAGNITUDE < '3.5', 'Less than 3.5'
REPORTED_MAGNITUDE >= '3.5' && REPORTED_MAGNITUDE <= '5.4', '3.5 to 5.4'
REPORTED_MAGNITUDE >= '5.5' && REPORTED_MAGNITUDE <= '6.0', '5.5 to 6.0'
REPORTED_MAGNITUDE >= '6.1' && REPORTED_MAGNITUDE <= '6.9', '6.1 to 6.9'
REPORTED_MAGNITUDE >= '7.0' && REPORTED_MAGNITUDE <= '7.9', '7.0 to 7.9'
REPORTED_MAGNITUDE >= '8.0' && REPORTED_MAGNITUDE <= '8.9', '8.0 to 8.9'
REPORTED_MAGNITUDE > '8.9', '9.0 and above'
I think this is like adding a calculated field. I'm just not sure how to do so in Arcade. Thank you!