Hello,
I'm trying to create an attribute rule that checks to make sure a divided highway exists for each median. Not sure if the logic is incorrect or if I'm misunderstanding the spatial relationship. It is flagging some correctly and some not. If a median does not have a divided highway on it, it may be correctly flagged, but another one close by will not get flagged (even tho it should). Here is the code and a picture. in the pic, the median running north south (greenish line) should also be red (error) as it doesn't have a divided highway underneath
This started with a clean dataset and deleted divided highways to test. In the clean data, each median will share the same route ID as a divided highway. I tried to flag errors based on attributes to keep it simple. I added in a spatial check but that still doesn't work.

// Check if the median is active (TO_DATE is NULL)
if (IsEmpty($feature.TO_DATE)) {
//Get Divided Highways
var highways = FeatureSetByName($datastore, "Divided_Highway_Export", ['ROUTE_ID'], false);
var hwyRouteID = $feature.ROUTE_ID;
// Filter highways by ROUTE_ID
var matchingHighways = Filter(highways, "ROUTE_ID = @hwyRouteID");
// Flag if NO matching highways were found
if (Count(matchingHighways) == 0) {
return true // flag median: no matching div hwy found
}
//Spatial check
var intersectingHighways = Intersects($feature, First(matchingHighways))
//Flag if no intersecting highway
if (intersectingHighways) {
return true //flag median
}
//If both conditions are true, pass validation
return false
} else {
return true; // Skip validation for retired medians
}
thanks for any help