I want to have a count of selected features, but sometimes there is no selection. If I use a text widget, connected to my layer, using Selected instead of Default, this will work fine as long as there is at least one feature selected. If there is none, the Count formula just displays the formula. Is there a workaround to display something when there is no selection to count?
I attempted using IIF() from Arcade and setting an empty data view. Neither one worked in my quick trial, but if it's possible in OOTB text widget, I feel like it would be down one of those roads.
https://developers.arcgis.com/experience-builder/guide/select-data/#data-details-and-data-views
https://developers.arcgis.com/arcade/function-reference/logical_functions/#iif
I thought maybe I could check "View for empty selection" and then give it filter like OBJECTID = -1, but that doesn't work. And I don't see anyway to get an Arcade expression to work in ExB.
Well, I just realized if I use the "Expression" tab under Dynamic Content for the text widget, instead of "Statistics", then I can give the expression a name, something like "No current selection" and it will display that text when there is no selection.
It would still be great if we could use Arcade expressions though, or at least have some sort of logic functions built into the expression editors.
Could you post your syntax? I tried the Expression tab and didn't get it to work. What happens with a blank name? Maybe you could even try grabbing an invisible unicode character?
I created an expression to display the words "Parcels Selected: " and then the number currently selected. Above it, where it normally says "Expression 1", I changed that to "No Parcels Selected"
So when there is a selection the text displays:
And when there is no selection, the text displays: