I'm trying to create an Arcade expression that will take a string attribute, split the string based on the "," separator, count the unique rows after this and then use that row count value as the value in the gauge.
Condensed example:
I have a feature service with an attribute "List" with values:
Row 1: Apple
Row 2: Apple, Banana.,
Row 3: Orange, Kiwi
I would want the gauge to show the value "4" because there are 4 unique values across these 3 rows. The Arcade expression works in the editor, but when returning to the Select Layer window, there is an error "Unable to execute Arcade script"
var species_set = {};
var total = 0;
for (var f in fs) {
var val = f["Primary_Target"];
if (!IsEmpty(val)) {
var items = Split(val, ",");
for (var i in items) {
var key = Trim(items[i]);
if (key != "" && !HasKey(species_set, key)) {
species_set[key] = true;
total++;
}
}
}
}
return total;