Looking to count the number of answers selected in a checkbox question? In this tutorial, we'll show you how. We'll also go a step further and show you how you can use the count in logic conditions for later questions and pages!
Set Up Count of Selected Answers
We will start by creating a checkbox question. In this example, we have listed all the many reasons you might love SurveyGizmo.
a subsequent page, we will click Action and select Hidden Value.
Paste the following merge code in the Populate with the following field:
[question("answer count"), id="2"]
Make sure to change the id to the question id for the above-created checkbox question.
Note: The answer count merge code will count other, write-in fields with a write-in response as 2 answers.
With the answer count for our checkbox question stored, we can now set up logic based on this value.
Set Up Logic Based on Selected Answer Count
Typically the selected answer count is set up for use in logic conditions in later questions and page. For example, respondents who select 4 or more options are jumped to a given page. And respondents who select less than 4 options are jumped to another page. Using the answer count merge code you can set this up!
In the example we described above we will need to set up Skip/Disqualify Logic, which we will cover just below. You can also set up Question Logic or Page Logic based off of this checked count.
Check it out in an example survey!
OR
Add this survey to your account!
Set Up Skip/Disqualify Logic Based on Selected Answer Count
To set up our example skip logic we will click the Skip/Disqualify Logic option between pages.
In the Logic Builder, we will select our Hidden Value (the one that stores the answer count merge code) in the first dropdown and then complete the logic rule. Finally, we will specify what we wish to have happen if the Logic passes.
In our example, we set up the below skip logic rules.
- One skip logic rule to send respondents to an alternate Terminal Page if they select less than 4 answers in the checkbox question.
- One skip logic rule to send respondents to the original Thank You Page if they select 4 or more answers in the checkbox question.
Set Up Question Logic Based on Selected Answer Count
In the above example, we set up Skip/Disqualify Logic. If you also wish to set up Question Logic, the questions must be on a page that follows the Hidden Value that stores the answer count. Follow the steps to set up Question Logic.
On a page that follows the check count Hidden Value, edit your question and go to the Logic tab. Select the option to Only show this question based on answers to previous questions or other logic conditions. Select your Hidden Value in the first dropdown and then complete the logic rule.
Click Save Question when you are finished with your logic rule. This question will now show only when the checked count meets the conditions you specified.
Now, if your checked count Hidden Value is on a page by itself you will probably want to automatically submit the page so as not to confuse respondents with a blank survey page. To do so, click the pencil icon above the right-hand corner of the page.
Click the Logic tab along the top of the panel and then select Yes for the Automatically submit the page, running all actions and custom scripts option.
Once you are finished with this panel, click Save Page. You will now see an icon in the upper left-hand corner of the page that lets you know the page is set to auto-submit!
Set Up Page Logic Based on Selected Answer Count
Setting up Page Logic using the checked count value is quite simple. On any subsequent page click the pencil icon above the right-hand corner of the page.
Click the Logic tab along the top of the panel and then select your Hidden Value (where you store the answer count merge code) in the first dropdown and then complete the logic rule.
Click Save Page when you are finished with your logic rule. This page will now show only when the checked count meets the conditions you specified.
Admin
— Dave Domagalski on 02/21/2018
@Shawkes: Thank you for your question!
I'm afraid that there is not a simple way to avoid having the other textboxes counted as two items. This is a limitation of the answer count merge code.
In order to work around this limitation, a customization via Custom Scripting would be needed:
https://script.surveygizmo.com/help
Another option is to consult with SurveyGizmo's Programming Services team regarding a custom solution:
https://www.surveygizmo.com/programming-services/
I'm sorry for the trouble!
David
Documentation Specialist
SurveyGizmo Customer Experience
— Bkhanduja on 02/21/2018
Is there a simple way to avoid having the other (specify) check box count as two items in the total rather than one? I have a study where I'm trying to narrow a list of all the things someone might like in a list of 12 to just the top 3. I only need to show the "top 3" question if they check 4 or more items, but if they check 2 closed end responses, and the other specify, this counts as 4 punches.
Admin
— Bri Hillmer on 06/29/2016
@AAO_COMM_USER: I took a quick look at your survey; I think there are a couple of things going on here. I will follow up with you a ticket to see about sorting these out!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— AAO_COMM_USER on 06/28/2016
I tried to hide the calculation page as instructed, but it's still showing up in the survey.
Admin
— Bri Hillmer on 04/27/2015
@Wendy: Thanks for taking a look at our documentation! I apologize for the confusion. I added a screenshot and some clarifying text to help you find this option!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Wbrown on 04/24/2015
Where do I find the Page Logic Action in the last screen shot?