Survey123: way to create 'count' field

8012
7
Jump to solution
02-27-2017 10:03 AM
CharlesBailey3
Occasional Contributor II

This seems pretty simple, must be missing something - how would I create a 'calculate' field in survey123 to count the number of submitted records that meet a certain criteria (e.g. ${defects}='n') to use in another calculation? The count function in S123 seems to apply to the number of multi-select responses... is there another way? Thanks, cob

1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

Sharing a sample XLSForm illustrating  use of count() and sum().

Added in version 2.1 https://community.esri.com/groups/survey123/blog/2017/06/02/world-milk-day-release-21 

View solution in original post

7 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Charles,

To clarify, are you asking for the number of repeats within a form that have an answer of a certain value?  If so, we don't have support for that functionality; additionally, I don't think the XLSform specification has a good way to evaluate that- there is a function for to get the answer at a specific repeat number and some functions that are evaluated over repeats, but not one that can pass a function to test at repeats.

0 Kudos
CharlesBailey3
Occasional Contributor II

Thanks James - that is indeed what I need. What gets me is I can see the repeats increment in the form preview, so it has to be in the table somewhere at that point. Is there any other way you know to sum or count the number of records (or I guess I should say the number of repeats) and display a calculation on that to the form user?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Charles,

Count and Sum functions are in the XLSForm spec (which is what we use as the design specification of Survey123), however they have not been implemented yet in Survey123.  The case you described of doing a conditional count (if ${defects}='n', add 1, else add 0) is more complicated; once the sum function is implemented, you could do this by creating an additional calculate question in the repeat that accomplishes the test with a 1/0 result and then sum that question.

0 Kudos
CharlesBailey3
Occasional Contributor II

That's what I was thinking - to use another field to sum the records. So I guess I will have to wait for the sum function - is it in the new beta version? Another thing is the nested repeats don't seem to be working right - if I start a 'plots' repeat for example, and within that place a 'samples' repeat, so that I want the individual samples to be allocated to a particular plot, but the survey result is that it duplicates each sample for each plot. So 4 plots with 14, 16, 18, and 20 samples becomes 4 plots with 68 samples each in the output. Is it a problem with my xls form, or is there any way to accomplish this in the current version of S123? Or should I ask this as a new question? Thanks James - cob

0 Kudos
JeffWard
Occasional Contributor III

JTedrick-esristaff‌, what is the time frame for the Sum and Count functions to be available? I was hoping to be able to get a count on some of my repeat questions to calculate a running score for the whole survey. Since you can set a maximum number of repeats they are being counted somewhere, how can i get to that count?

Jeff Ward
Summit County, Utah
0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Jeff,

We hope to have the sum and count in Survey123 before UC.  I'd encourage you to join the Early Adopter Community (https://bit.ly/Survey123beta) if you haven't already to be able to test as we develop the feature.

0 Kudos
IsmaelChivite
Esri Notable Contributor

Sharing a sample XLSForm illustrating  use of count() and sum().

Added in version 2.1 https://community.esri.com/groups/survey123/blog/2017/06/02/world-milk-day-release-21