Finding DISTINCT features using Arcade in List widget in Operations Dashboard

781
1
03-14-2022 01:03 PM
Labels (1)
LindaSlattery
Occasional Contributor

I am trying to create a list with only distinct features from my table in Operations Dashboard. I am using the following Arcade script:

var provider = Distinct($datapoint["provider_name"])
return {
attributes: {
provider: provider
}
}

In the line item template in the list, I call it using {expression/provider}. I do not get any errors and it results in a provider name being listed, but I do not get unique names. Rather, it lists them all. Any ideas how to correct this?

 

Thanks!

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

The distinct function returns either an array or a FeatureSet, depending on the input.

The expression you have written here is in the dashboard formatting profile of Arcade, which cannot do what you're trying to accomplish. You're telling it to return the distinct values of the provider name of a single datapoint. The function treats this as an array with a single item in it:

jcarlson_0-1647311277878.png

Consider using a Data Expression, similar to this example.

Yours might look like this:

var portal = Portal('https://www.arcgis.com/');

var fs = FeatureSetByPortalItem(
    portal,
    'your itemid',
    0,
    ['provider_name'],
    false
);

return Distinct(fs, 'provider_name') 
- Josh Carlson
Kendall County GIS
0 Kudos