survey123 count filtered by selected choice

2710
4
06-13-2017 01:20 PM
CharlesBailey3
Occasional Contributor II

Now that repeat aggregation is available in S123, is there a way to count only records in which a particular choice was selected? Basically to filter the count by the selection value - say like  count(${defects} = 'none') but that doesn't work; I guess because it's boolean (?)

The aggregation will be of limited use to me without this capability. Thanks! cob

0 Kudos
4 Replies
JamesTedrick
Esri Esteemed Contributor

Hi there,

The count function doesn't support a comparison function.  This could be accomplished by having an additional calculate field in your repeat with the comparison inside an if statement, resulting in 1 if true and 0 if false- then you would need to sum the new field to get the number that meet the criteria.

CharlesBailey3
Occasional Contributor II

Yes I had that same idea today and it almost works, but it seems like the repeats are summed like strings instead of numbers when the if statement is used. So when I do if(${cond1}='n' and ${cond2}='n', 1,0) they are summed like this - 1st iteration = 1, 2nd = 11, 3rd = 111 and so on. Can I use the bind ESRI type to override it? Thanks, cob

PatricWiström
New Contributor

Hi Charles!

Did you ever get this to work? I'm trying something similar but so far no luck. Seems like a pretty useful function so I hope it gets implemented as a standard function in future releases.

/Patric

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Patric,

To get this to work successfully, a column called bind::type needs to be added and the value set to integer for the question with 1/0 values.

0 Kudos