I am working on configuring the pop-ups on our hydrant layer to automatically pull in the most recent date inspected from a different layer: Hydrant Inspection layer. I want it to pull the most recent date if there is more than one date inspected for a given hydrant, which in many cases there are. I have been wracking my brain on an arcade statement but nothing I get works. I am not sure if I need to do an Intersects function with hydrant or OrderBy or First. I am lost. I would even love to have it pull in as an attribute rule inside of ArcGIS pro for the layer but for now I will settle on getting an arcade for the pop-up. If anyone has any suggestions, they would be much appreciated.
Solved! Go to Solution.
var all_inspections = FeaturesetByName($map, "Inspections")
var hydrant_id = $feature.HydrantID
var hydrant_inspections = Filter(all_inspections, "HydrantID = @hydrant_id")
var sorted_inspections = OrderBy(hydrant_inspections, "InspectionDate DESC")
var latest_inspection = First(sorted_inspections)
if(latest_inspection == null) { return "No inspection found" }
return latest_inspection.InspectionDate
var all_inspections = FeaturesetByName($map, "Inspections")
var hydrant_id = $feature.HydrantID
var hydrant_inspections = Filter(all_inspections, "HydrantID = @hydrant_id")
var sorted_inspections = OrderBy(hydrant_inspections, "InspectionDate DESC")
var latest_inspection = First(sorted_inspections)
if(latest_inspection == null) { return "No inspection found" }
return latest_inspection.InspectionDate