Hello,
I'm new in working with Arcade expressions in the Dashboard.
What I want is to split the values in the 'split' field which are separated by commas while preserving the original ID of each value. How could I do this? I
// Split values corresponding to Action
// Reference layer using the FeatureSetByPortalItem() method.
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'a616dac6c1834fedb0fad1860c14234e' , 1, ['*'], false);
// Empty dictionary to capture each hazard reported as separate rows.
var choicesDict = {'fields': [{ 'name': 'split', 'type': 'esriFieldTypeString'}, { 'name': 'ID', 'type': 'esriFieldTypeString'}],
'geometryType': '',
'features': []};
var index = 0;
// Split comma separated hazard types and store in dictionary.
for (var feature in fs) {
var split_array = Split(feature["Action"], ',')
var count_arr = Count(split_array)
for(var i = 0; i < count_arr; i++ ){
choicesDict.features[index++] = {
'attributes': { 'split': Trim(split_array[i])
}
}
}
for(var i = 0; i < count_arr; i++){
choicesDict.features[i++] = {
attributes: {
ID: feature["ID_bins"]
}
}
}
}
var result = Replace(choicesDict, "_", " ");
// Convert dictionary to featureSet.
var fs_dict = FeatureSet(Text(result));
// Return featureset after grouping by hazard types.
return GroupBy(fs_dict, ['split'],
[{ name: 'No', expression: 'split', statistic: 'COUNT' }]);