Validating select_multiple responses

390
2
Jump to solution
03-11-2020 11:21 AM
Soper_Chuck
New Contributor III

I'm relatively new to Survey123. I'm building a survey with about 50 questions. The data output file has a strict format. About 6 or 8 questions are multiple choice with 5 to 8 questions like this:

  1. Question 1
  2. Question 2
  3. Question 3
  4. Question 4
  5. None

Users can select all that apply (select_multiple) except 'None' cannot be combined with any other answers. The data output for questions like this is required to be '1,2,4' or '5' but '4,5' should never be accepted. What is the best strategy for validating this question and preventing the user from submitting invalid data? I can't validate after submitting survey because that would require contacting the user. Thanks.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

I just had to do this.  Basically if None is selected then the total selected must be 1.  If None is not selected then no prob.

constraint

if(selected(., "None"), count-selected(.)=1,1)

View solution in original post

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

I just had to do this.  Basically if None is selected then the total selected must be 1.  If None is not selected then no prob.

constraint

if(selected(., "None"), count-selected(.)=1,1)

0 Kudos
Soper_Chuck
New Contributor III

Excellent. Thanks for the fast response. Initially, it wasn't working for me because my list item value for "None" was 8 which needed to be in quotes like this:  if(selected(., '8'), count-selected(.)=1,1)

To verify some formulas I used a calculation in a note field. Now, I'm getting a "Data values are valid" alert when attempting to submit the survey. As I said, I'm new to Survey123. Thanks again.

0 Kudos