Arcade function to show unique values (remove duplicate values)

2508
8
02-18-2021 05:42 PM
Status: Already Offered
Labels (2)
LindsayRaabe_FPCWA
Regular Contributor

When using the Table Attribute dynamic text function in ArcGIS Pro you can return a string of values visible in the map frame (i.e.1, 2, 3, 4,...). Sometimes you may have a dataset with multiple features with the same value (i.e.1, 2, 2, 2, 3, 3, 4,...).. By using this function in it's current format, you would see the results as per the example given, but sometimes you may want to only see Unique values (i.e. 1, 2, 2, 2, 3, 3, 4 would be returned as 1, 2, 3, 4). It would be good if there was an Arcade function that shows unique values, removing any duplicates (suggestion below). 

LindsayRaabe_FPCWA_0-1613698748784.png

 

This post is another example of where this function would be useful: https://community.esri.com/t5/arcgis-pro-questions/how-to-remove-duplicate-values-from-dynamic-text-... 

8 Comments
MehdiPira1

Great idea @LindsayRaabe_FPCWA !

CraigWilliams
Status changed to: Already Offered

You can put the values into an array and then use the Distinct function for this. This will work with numbers or text in an array, for example:

 

Distinct(["1", "2", "2", "2", "3", "3", "4"])

 

or

 

Distinct([1, 2, 2, 2, 3, 3, 4])

 

The Split function can help you construct an Array if you don't have one already.

LindsayRaabe_FPCWA

@CraigWilliams  I'm not sure this works correctly in the Dynamic Text function. As per screenshot below, I don't get any values returned - just the delimiter. 

LindsayRaabe_FPCWA_0-1613703232889.png

LindsayRaabe_FPCWA_0-1613703307048.png

 

 

LindsayRaabe_FPCWA

Support case lodged. #02745001 Removing duplicate values using DISTINCT arcade function in table value dynamic text not working

LindsayRaabe_FPCWA

Just received this update;

 

"Thank you for your patience as we have investigated this issue. I just wanted to update you on this case. After extensive testing, it does appear that there is an issue with the Distinct function when used in the Table Attributes option for Dynamic Text. We were able to replicate this issue and found that a blank output was returned when applying the Distinct function as outlined in the Esri Community post that you sent through. 

Because of this, we have lodged a bug on the issue BUG-000137676: Unable to remove duplicates using 'Distinct' Arcade function in Table Attribute Value Dynamic Text in ArcGIS Pro. "

 

Hopefully see a fix in 2.8!

SamJeneCastro23

@LindsayRaabe_FPCWA Is there a fix for this in 2.8.1?

KoryKramer

The bug mentioned above is showing as In Product Plan on the support site: https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEzNzY3Ng==

Meaning that it is not fixed in 2.8.1 or the current version of Pro which is 2.9.  But it looks like work is being done.

LindsayRaabe_FPCWA
Not that I've figured out or that ESRI support has shown me. Not really satisfied with the explanation I got from them on this one.