Prevent Selecting “None of the Above” with any Other Option – XLSForm Constraint Tutorial and Template
I want to share with you a useful XLSForm constraint that you can use when you create digital questionnaires for Kobo Toolbox, ODK, Ona, or SurveyCTO. Someone recently asked me this question:
“How can I create a constraint such that respondents can’t select “I don’t know” and another option. I want to create a constraint that prevents selecting “I don’t know” and any other option from a multiple_select question.”
This is such a good question. And it is very common in humanitarian and development questionnaires, where we give a list of options and say “select ALL that apply”. And then at the bottom of the list, we might have options like:
- Not applicable
- I don’t know
- None of the above
But it wouldn’t make sense if the questionnaire allowed you to select “None of the above” with another option also.
So…there is a great constraint that you can use in your XLSForm to prevent this from happening.
Please watch this video to see the full explanation of how to create the constraint and how to construct the formula!
If you want to download the XLSForm Constraint Template, click here to go get your download.
What this XLSForm Constraint is Trying to Prevent
- We don’t want to allow anyone to select “none of the above” when they’ve selected any other answer.
Or we could also say…
- We don’t want to allow anyone to select “none of the above” when they’ve selected more than one answer.
When we emphasise “more than one” answer, it indicates that part of the logic of our constraint will be looking at counting how many answers the respondent selected. So let’s dig in…
Set Up the Question in XLSForm
The important elements of the question set-up are as follows:
- It applies to a “select_multiple” question
- The choice list is under the “choices” tab.
- Options include choices such as “I don’t know”, “none of the above”, or “not applicable”
- The respondent sees the “label” for each option when he or she fills out the questionnaire
- The “name” for each label – is the variable name used in the constraint to refer to that option
Two Parts to the XLSForm Constraint Formula
The first part of the formula that you need to know is:
selected(.,'none')
You can read more about this function on the OpenDataKit website. It means that the respondent selected the choice “none” in the question that they’re currently answering. The “.” refers to the answer currently being input into the questionnaire.
The second part of the formula that you need to know is:
count-selected(.)>1
You can read more about this function on the OpenDataKit website. However, the main interpretation is that the form will count how many choices were selected in the current question, and it will check if that count is greater than 1.
So there is a Problem when…
The problem occurs when the respondent has
selected(.,'none') and count-selected(.)>1
The “and” means both these things have to be true for the problem to exist. So, if the respondent hasn’t selected none, then it’s okay if count-selected(.) is greater than one.
Writing the Final XLSForm Constraint
You can use “not()” in the XLSForm constraint formula to show that this situation is “not allowed” to occur when the form is being filled out. The full constraint formula is:
not(selected(.,'none') and count-selected(.)>1)
The interpretation of that formula in plain-English would be: you are “not allowed” to “select none” if you’ve “selected more than one choice”
Enter this formula into the “constraint” column of the XLSForm. If you want to know how to create your own Blank XLSForm Template, you can learn how to here.
By Janna
Janna is an aid worker, an engineer, a mom, a wife, and a self-declared data-lover! Her mission is to connect with every field worker in the world to help the humanitarian sector use information management and technology to make aid faster and more accountable.