I hope this is the right place to post this.
From searching around it appears that you cannot dynamically display a count of related features on a label or map tip, but the workaround is to write the information to a field, and then use that within the necessary expressions.
I can successfully write the total number of related features to a field with the following code:
var relatedFeatures = FeatureSetByRelationshipName($feature, "<relationship_class_name>")
return Count(relatedFeatures)
That works great and returns a total of 5, which is how many features are related in the one feature that I am testing this on. The image below shows the 5 related features.
However, the cable in that list is a sub-relation, and I don't want to include that feature in my count. In this particular example, I want the final count to show as 4. I was attempting to use the Filter() function to accomplish this, but I keep running into an invalid where clause error when adding the second line shown in the code below:
var relatedFeatures = FeatureSetByRelationshipName($feature, "<relationship_class_name>")
var filteredFeatures = Filter(relatedFeatures, "Data Type != 'cable'")
return Count(filteredFeatures)
I have attempted too many variations to recall. Any tips to point me in the right direction? I've been scouring through Google and ChatGPT and all of the examples returned lead me to exactly what I have written above.
Thanks!
Solved! Go to Solution.
You also have a space in the field name, which is probably its alias. Use the actual field name.
Here is the actual error message:
You have to use "<>" instead of "!=" in SQL statements
var filteredFeatures = Filter(relatedFeatures, "Data Type <> 'cable'")
Thank you for the response. That is one of the variations that I tried. It still returns the same message.
You also have a space in the field name, which is probably its alias. Use the actual field name.
Thank you! I did try that in other variations, but it was likely in completely different things that I was trying at the time. I probably also still had the "!=" operator in there when attempting it. Much appreciated!