Modified to sort values (Line 10), exclude 0 values (Line 7) and return just the output value (Line 18).
var poly1 = FeatureSetByName($map, "FPC Plantations")
var intersects = Intersects(Geometry($feature), poly1)
var distinct_planting = []
var display_output = ""
for(var f in intersects) {
iif(f['EstabYear']==0,"",Push(distinct_planting, f['EstabYear']))
}
distinct_planting = Distinct(Sort(distinct_planting))
for (var pyear in distinct_planting) {
display_output = display_output + distinct_planting[pyear] + ' '
}
display_output = Trim(display_output)
return(display_output)
And further modified to separate with commas and spaces ', ' (Line 13) plus removing the last comma and space (Line 16) which negates the need for the Trim function which only removed the original trailing space.
var poly1 = FeatureSetByName($map, "FPC Plantations")
var intersects = Intersects(Geometry($feature), poly1)
var distinct_planting = []
var display_output = ""
for(var f in intersects) {
iif(f['EstabYear']==0,"",Push(distinct_planting, f['EstabYear']))
}
distinct_planting = Distinct(Sort(distinct_planting))
for (var pyear in distinct_planting) {
display_output = display_output + distinct_planting[pyear] + ', '
}
return(Left(display_output, Count(display_output)-2))
Lindsay Raabe
GIS Officer
Forest Products Commission WA