The goal of this code is to find the top 3 most planted trees in each polygon and rank them in a popup. The code below accomplishes that, but it returns the code of the domain and not the description.
For example, I want the list to look like this "1. Maple 2. Oak 3. Hickory", but arcade returns this instead"1. AC 2.QU 3. CA".
I have attempted to use DomainName to return the description, but I am having difficulty. When I run the code below in an attempt to return the description, nothing is returned. Please help me return the description and not the code for this feature class.
var trees = FeatureSetByName($map, "Trees - Trees")
var countspecies = Intersects(trees, $feature)
var stats = Groupby(countspecies, "commonname",[
{name: "total" ,expression: "commonname", statistic: 'COUNT'}
])
var topspecies = Top(OrderBy(Filter(stats, "commonname <> ''"), "total desc"), 3)
var result = 'The top species in this tract are:'
var num = 0
for (var item in topspecies){
num++
var num_species = item["total"]
var species_name = DomainName(item,FeatureSetByName($map, "Trees - Trees"), "commonname")
result += TextFormatting.NewLine + num + ". " + " " + species_name + " " + num_species + " " + "planted"
}
return result