I'm using the below code, attempting to filter a related table for inspections to show a message in the pop-up
var gid = $feature.globalid
var signcount = filter(FeatureSetByName($map,'Sign_Information', ['*']),'parentglobalid = gid')
var x = typeof(signcount)
var sign = count(signcount)
console("sign = "+sign)
var p = ""
when(sign > 1, p = "There are "+sign+" sign surveys on this asset",
sign == 1, p = "There is 1 sign survey on this asset",
p = "There are no sign surveys recorded for this asset")
This just fails and errors in the expression builder.
Further interrogation in Pro gives
I have consoled out the type of the signcount to rule out issues there.
What's the inevitably very obvious thing I'm missing?
See below, but looks like I've sorted one problem at least.
The filter wasn't working properly as I hadn't done the SQL query correctly, needed an "@" before "gid" to set it as an arcade variable.
Still not working in the actual pop-up, but it is working in the expression builder.
Your filter clause is failing due to incorrect syntax. "gid" is a string variable, not the actual value for parentglobalid. Use this syntax
var signcount = filter(FeatureSetByName($map,'Sign_Information', ['*']),"parentglobalid = '" + gid + "'");