Hello,
I don't know anything in Arcade but I am following someone else code to split the answer of a multiselect question and generate a chart that counts each answer separatly.
The code is as follow
// Reference layer using the FeatureSetByPortalItem() method.
var fs = FeatureSetByPortalItem(
p,
'2ee459d7a5914544bb18ea293dd3be41',
0,
['energy_sel_one'],
false
);
// Create empty array for features and feat object
var features = [];
var feat;
// Split comma separated hazard types and store in dictionary.
for (var feature in fs) {
var split_array = Split(feature["energy_sel_one"], ',')
var count_arr = Count(split_array)
for(var i = 0; i < count_arr; i++ ){
feat = {
'attributes': {
'split_choices': Trim(split_array[i])
}
}
Push(features, feat);
}}
// Empty dictionary to capture each hazard reported as separate rows.
var choicesDict = {
'fields': [
{ 'name': 'split_choices', 'type': 'esriFieldTypeString'}],
'geometryType': '',
'features': features
};
// Convert dictionary to featureSet.
var fs_dict = FeatureSet(choicesDict);
// Return featureset after grouping by hazard types.
return GroupBy(fs_dict, ['split_choices'],
[{ name: 'split_count', expression: 'split_choices', statistic: 'COUNT' }]);
However when I run the expression, it returns the following error

Could anyone help me in fixing it knowing that I don't know anything about arcade.
Thank you