Expression to count the number of features where a condition is true.

1908
3
Jump to solution
10-13-2022 08:14 PM
Labels (1)
GregReinecke
New Contributor III

In ExB I'd like to count the number of features where the condition met is true. I have a number of features with a text field called "Is an Issue Flagged?". If the value is "Yes" (i.e True) then I'd like to count them. So if I have 6 features with the field   Is an Issue Flagged  = "Yes"   I'd put a 6 in a dynamic text box.

Here is my expression that doesn't work:    IF {Is an Issue Flagged?} = "Yes" THEN  COUNT({ObjectID}) END

Thanks in advance.

GR

Tags (2)
1 Solution

Accepted Solutions
WFNSProject
New Contributor

The approach is likely not an arcade solution but the approach you presented is perfect. I did actually use views in ExB and  counted items from there. I was just trying to skip that step. Thanks you. 

View solution in original post

3 Replies
Kara_Shindle
Occasional Contributor III

Where is this calculation in the experience?  If you are able to use Arcade, I saw this Geonet response that filtered by the field and I think you could do something similar.

https://community.esri.com/t5/arcgis-online-questions/arcade-totaling-field-values-of-features-conta...

alternatively,

var fc = FeatureSetBYName($datastore, "layername", ["Is an issue flagged"], True);

var cnt = 0;

for (var yes in fc) {
    if (yes.is an issue lagged == "yes")  {
        cnt += 1;
    }
}
return cnt;

 

I based the above off of a solution here: https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-arcade-filter-function-issue/td-p/...

WFNSProject
New Contributor

The approach is likely not an arcade solution but the approach you presented is perfect. I did actually use views in ExB and  counted items from there. I was just trying to skip that step. Thanks you. 

jcarlson
MVP Esteemed Contributor

ExB doesn't have much in terms of expressions. Certainly not conditional statements. Data source views are (currently) the only way to accomplish this.

 

- Josh Carlson
Kendall County GIS