Expression for report template, to count the number of a specific response across a range of select_one questions?

228
4
Jump to solution
05-30-2019 06:19 PM
Highlighted
New Contributor II

I have a select_one question that occurs multiple times (+50) throughout my survey asking whether an item is Compliant (C) or Non-Compliant (NC). Each occurrence has a different name to identify it to the specific item.

In my custom report I want to generate an overall count of the number of C. Is there an expression available that would automatically count how many items were complaint that looks at all these select_one questions, or even the entire survey's responses to questions/select_one questions (as the C / NC responses are unique to this question) and count the occurrences of 'C' so I have a tally of the number of compliant as an output.

Cheers

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor II

Thanks James.

As we had multiple instances of this question required, we ended up using a concatenate function to write it for us a few hundred times. Worked a treat!

View solution in original post

Reply
0 Kudos
4 Replies
Highlighted
Occasional Contributor II

Hi Thomas

I am intruiged to see the design of your survey - would you want to share it? I might have a good alternative way of capturing compliance records or any type of scenario where a user should go through a list of items from top to bottom:

https://esri-southafrica.blog/2017/12/14/survey123-with-a-single-attribute-for-repeating-generic-que...

Regarding the count of compliance - why dont you do a calculation in the survey to capture the number of occurrences as they happen? Perhaps if you share your survey i could have a look

Highlighted
New Contributor II

Hi Deon,

Thanks for getting back to me so quickly. I've attached an example of the form section of interest - essentially a count (by type) of the responses to the select one fields is the goal.

I've used counters in repeats before which definitely work well, thank you for your link! I wonder if we could translate the method across to fields outside of repeats?

I'm just adding fields together at the moment as a calculation to produce the count as follows:

if(selected(${question1}, 'C'), 1, 0) + if(selected(${question2}, 'C'), 1, 0) + if(selected(${question3}, 'C'), 1, 0)  and so on... But I'm thinking there might be a better way?

Many thanks,

Thomas

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Thomas,

There isn't a built-in function in the feature report, but you could have some logic in the form to tally the responses.  It's a bit annoying to set up, but the simplest way to do this would be to have a (pair of) calculate field(s) that use an if statement to turn 'C' into 1:

if(selected(${Check1}, 'C'),1,0) + if(selected(${Check2}, 'C'),1,0) + if(selected(${Check3}, 'C'),1,0) + ...

 

Highlighted
New Contributor II

Thanks James.

As we had multiple instances of this question required, we ended up using a concatenate function to write it for us a few hundred times. Worked a treat!

View solution in original post

Reply
0 Kudos