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 Alchemer.
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!
Check it out in an example survey!
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.