Select to view content in your preferred language

Arcade Symbology Expression

439
2
03-12-2024 01:09 PM
Labels (1)
KarynaB
Occasional Contributor

I have a joined view layer that was created by joining an invasive plants point layer with its related treatment table. The purpose of this layer is to symbolize whether or not an invasive plant has been treated within the last year based on updates made to the treatment tables. 

I thought the code for this would be relatively simple, however, I have run into a few roadblocks. There are multiple treatment records for each individual point, and to ensure that the symbology is accurate, they need to be organized so that the computer only references the latest treatment date. I have done this before with pop-ups using the 'OrderBy' function, but that is not available to me in the symbology expressions page because it is only available for featuresets, not solely features. I haven't been able to find another function that accomplishes this same task, does anyone know of a workaround for this? 

Thank you!

var order = OrderBy($feature, "Treat_Date DESC");
var latest = First(order);
Iif(DateDiff(now(), latest.treat_date, 'months') < 12, "Treated", "Requires Treatment")

 

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

If I understand your scenario correctly, each feature may have a number of related features. You want to sort those related records, not the feature itself.

var relatedRecords = FeatureSetByRelationshipName($feature, "the relationship name");
var order = OrderBy(relatedRecords, "Treat_Date DESC");
var latest = First(order);
Iif(DateDiff(now(), latest.treat_date, 'months') < 12, "Treated", "Requires Treatment")
0 Kudos
KarynaB
Occasional Contributor

I had originally created a hosted feature layer view by joining the points layer with its related table, but I now realize that I can sort the fields in that join to only include the newest treatment date. Then, I would only need to use the last line of code to achieve the symbology that I am looking for. Thank you for your help!

0 Kudos