Select to view content in your preferred language

Arcade in List (advanced formatting): filter unique values

1305
3
07-20-2023 06:18 AM
Labels (1)
YvanS
by
New Contributor II

Hello,

 

I would like to filter data in a Dashboard List element to display only unique attribute values.

The dataset looks something like this:

SiteYearSpeciesCountlatitudelongitude
S12019Sp112483.27315-100.353
S12018Sp212083.27315-100.353
S12020Sp2883.27315-100.353
S12020Sp3183.27315-100.353
S22018Sp18663.27315-100.359
S22021Sp1163.27308-100.359
S32019Sp12683.234-100.675
S32018Sp12583.234-100.675
S32020Sp44083.234-100.675
S42021Sp15056.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

List.PNG

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.

3 Replies
YvanS
by
New Contributor II

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}

 

EdmundEkanem1
New Contributor

@YvanS Have you found a solution to this yet? I am trying to do the same thing 

0 Kudos
YvanS
by
New Contributor II

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:

  • Data: Categories from: Defined values (I had to manually type each different category); Value type: String
  • Selector: Operator: contains

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").
Untitled.png

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).

0 Kudos