Hello,
I would like to filter data in a Dashboard List element to display only unique attribute values.
The dataset looks something like this:
Site | Year | Species | Count | latitude | longitude |
S1 | 2019 | Sp1 | 124 | 83.27315 | -100.353 |
S1 | 2018 | Sp2 | 120 | 83.27315 | -100.353 |
S1 | 2020 | Sp2 | 8 | 83.27315 | -100.353 |
S1 | 2020 | Sp3 | 1 | 83.27315 | -100.353 |
S2 | 2018 | Sp1 | 86 | 63.27315 | -100.359 |
S2 | 2021 | Sp1 | 1 | 63.27308 | -100.359 |
S3 | 2019 | Sp1 | 26 | 83.234 | -100.675 |
S3 | 2018 | Sp1 | 25 | 83.234 | -100.675 |
S3 | 2020 | Sp4 | 40 | 83.234 | -100.675 |
S4 | 2021 | Sp1 | 50 | 56.001 | -112.675 |
I would like the List element to only display unique Site values (S1, S2, S3, S4). I need to keep the Year and Species attributes for Category Selector filters (to decrease the list based on those selectors), so doing the filtering upstream in Data Expression won't work.
I'm thinking I need to use the Distinct function but I'm not sure if:
1) this type of filtering is allowed at all in Advanced Formatting, and
2) how to call the values returned from the Distinct function in List>List options
Esri tutorials about Advanced Formatting for Lists are usually about visualizing data (not filtering it), and all the answers I can find in this forum on filtering unique/duplicate values relate to Data Expression.
Any help is appreciated.
Someone replied to the same question on gis stack exchange (https://gis.stackexchange.com/questions/464487/esri-dashboard-arcade-in-list-advanced-formatting-fil...) but their suggestion (below) did not fix the problem. I still get a list of Site names with as many rows as the original dataset (i.e. not a list of unique Site names).
Advanced formatting:
var uniquename = Distinct($datapoint.Site);
return {
attributes: {
unique : uniquename
}
}
Line item template:
{expression/unique}
@YvanS Have you found a solution to this yet? I am trying to do the same thing
Hi EdmundEkanem1,
I found a work-around that works for me but it's not really a solution to filtering unique values in a List.
My main problem was using Category Selectors to filter a List, based on information present in fields of the feature layer used to create the List.
The solution I found was to adapt the Category Selectors instead of adapting the List.
The Category Selectors used to get their categories from Grouped values (in option Data/Categories from). They now use:
This works for me because the List summarizes information in its fields. For example, the field "Year" used in a Category Selector, has all the years for which there is data in my main dataset shown in the Dashboard map.The Category Selector then just checks if the Years field contains the Defined values (say "2011").
In my case, I have two distinct feature layers (the main dataset for the map, and the summarized dataset for the List). I created my summary file in R (because this is where I was working on the main dataset).