Hello,
I am trying to make an attribute rule that calculates the length of Water Pipe within a polygon. I have had some success with this arcade code:
var WatPipe=featuresetbyname($datastore,'WAT_Pipe',['*'])
Var Pipewithin=contains($feature,WatPipe)
return sum(length(Pipewithin))
After getting this to work, I realized it was grabbing all the water pipes contained in the polygon which included the abandoned and removed water pipes.
Is there away to filter the feature set first? I tried this and didnt have any luck
var WatPipe=filter(featuresetbyname($datastore,'WAT_Pipes',['*']),'status= in service')
var Pipewithin=contains($feature,WatPipe)
return sum(length(Pipewithin))
Please help
Solved! Go to Solution.
the filter statement in the Filter() function has to be a valid SQL statement.
You're using "status = in service", which is invalid, because status seems to be a text field, so the text value should be enclosed in single quotes.
You shouldn't need to call Sum(). Length(featureset) already returns a single numeric value.
Try this:
var WatPipe = Filter(FeaturesetByName($datastore, 'WAT_Pipes', ['*']), "status = 'in service'")
var Pipewithin = Contains($feature, WatPipe)
return Length(Pipewithin)
the filter statement in the Filter() function has to be a valid SQL statement.
You're using "status = in service", which is invalid, because status seems to be a text field, so the text value should be enclosed in single quotes.
You shouldn't need to call Sum(). Length(featureset) already returns a single numeric value.
Try this:
var WatPipe = Filter(FeaturesetByName($datastore, 'WAT_Pipes', ['*']), "status = 'in service'")
var Pipewithin = Contains($feature, WatPipe)
return Length(Pipewithin)
Thanks that worked!!