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!
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:
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')
@jcarlson where do we insert this code, still in the advanced formatting? I am trying to do the same thing now. it also seems like the FeatureSetByPortalItem is not active on my end. Please could you any update on this?
Nah, follow the link in the original post. Data Expressions are separate data sources; you can create one when you define the data source for a widget.