I am trying to pull from a feature set the location by filtering it by the relationship ID. I have similar formulas that work fine, but for some reason I am having trouble with this one. I have the following, could someone please help? The below rule is working, but pulling the first row from attribute table. Thanks
var Land = FeatureSetByName($datastore, "Land", [ "Location","Name","County","School_District","ID"]);
VAR LOCATION = FILTER(LAND,"ID=$feature.ID")
FOR(VAR I IN LAND)
RETURN I.LOCATION
Solved! Go to Solution.
You're telling your DBMS to use the literal SQL query "ID = $feature.ID". This isn't a valid where clause and so it fails.
What you want to do is store the $feature.ID in a variable and use the @ notation of Filter() to take care of the type formatting for you.
Also, you aren't looping over the filtered feature set, but over the whole table...
var Land = FeatureSetByName($datastore, "Land", [ "Location", "Name", "County", "School_District", "ID"]);
var id = $feature.ID
var related = Filter(Land,"ID=@id")
var location = First(related)
if(location == null) {
// no related features found -> return a default value
return null
}
// else return the related feature's ID
return location.ID
Hi,
Do you mean to loop through the original dataset or the filtered dataset? Also, I'm not sure if the curly braces are required in Arcade.
https://developers.arcgis.com/arcade/guide/logic/#for-loops
Does the following work?
var Land = FeatureSetByName($datastore, "Land", [ "Location","Name","County","School_District","ID"]);
VAR LOCATION = FILTER(LAND,"ID=$feature.ID")
FOR(VAR I IN LOCATION ) {
RETURN I.LOCATION
}
You're telling your DBMS to use the literal SQL query "ID = $feature.ID". This isn't a valid where clause and so it fails.
What you want to do is store the $feature.ID in a variable and use the @ notation of Filter() to take care of the type formatting for you.
Also, you aren't looping over the filtered feature set, but over the whole table...
var Land = FeatureSetByName($datastore, "Land", [ "Location", "Name", "County", "School_District", "ID"]);
var id = $feature.ID
var related = Filter(Land,"ID=@id")
var location = First(related)
if(location == null) {
// no related features found -> return a default value
return null
}
// else return the related feature's ID
return location.ID
Very Helpful. Thank so much!