Select to view content in your preferred language

Text Widget to Dynamically Count Features based on Field Value

171
4
2 weeks ago
DarraghOSullivan
Frequent Contributor

I'm trying to set up a text widget with a dynamic count of features filtered by a field (e.g. RecordType = Club). The count will change based on map extent and user-selected filters. But I've found that:

  1. There is no direct way to filter based on a field within the text widget.
  2. The Expression module does not accept sql statements like 'where'.
  3. I have fields that are only populated for clubs, e.g. 'ClubAffiliation' but a Count of these returns the count of distinct values, not the total number of values (as stated in the documentation).

My data has a large number of features (up to 20,000) and will have a lot of concurrent users, so I'm conscious of performance. So trying to avoid using Arcade or creating Views just for this purpose.

Any ideas or wisdom, thanks?

0 Kudos
4 Replies
StuartMoore
Frequent Contributor

we have a similar use case and use an imbedded dashboard element

StuartMoore_0-1751434277677.png

that only shows the number based on the current users audit failures
this is the dashboard bit

StuartMoore_1-1751434331328.png

 

// Write an expression that returns a FeatureSet.
// Documentation: https://arcg.is/3c419TD
// Samples: https://arcg.is/HPbi00

var features = FeatureSetByPortalItem( Portal('https://www.arcgis.com'), '3e9...790d', 1, ['*'], false);
var currentusr = GetUser().username;
var filterwhere = "Audit_Status in ('In Progress') and Survey_by = '"+currentusr+"'" //'Open','In Progress','Query'
var result = Filter(features, filterwhere);
return result;

i set the dashboard to refresh every 15 minutes or so

see if that fits the bill

 

Stu

0 Kudos
DarraghOSullivan
Frequent Contributor

Thanks @StuartMoore . I think with Arcade now possible within a text widget in ExB, it would be more efficient than a dashboard embed. I also need continuous refresh, even as the main map pans etc. 

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

JeffreyThompson2_0-1751468336569.png

Could you set up Data Views to handle the SQL part of the problem? I don't think this should significantly impact performance.

You should be able to use Count on the OBJECTIDs to find the total number of records in the filtered dataset.

GIS Developer
City of Arlington, Texas
0 Kudos
DarraghOSullivan
Frequent Contributor

Thanks @JeffreyThompson2 ,

Yes I might do that but was trying to avoid views with thousands of features if possible for something that seems quite simple! If setting up views, is it more efficient to set them up within ExB or externally, where I can reduce the fields etc?

0 Kudos