Select to view content in your preferred language

Restricting Users to a Maximum Number of Selected Questions

3384
5
Jump to solution
09-20-2016 09:04 PM
WengNg
by
New Contributor III

Hi,

I'm trying to add a constraint in which the user will only be allowed to select a maximum number of answers in multiple selection choice question. 

Is there a way I can do it in Survey 123?

My initial approach was to calculate the number of selected questions using the count-selected(question) formula and use the returned number as a constraint but it did not work. 

Is this currently possible and if yes, is there a sample formula to show how I should put this in the constraint column?

Thanks,

Weng

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

May be the attached XLSFile will help. Note that the syntax of the expression is exactly the same, regardless of it  being in used for the constraint or relevant expression. For example:

count-selected(${colors})<3

View solution in original post

5 Replies
IsmaelChivite
Esri Notable Contributor

Hi. Yes. You can use count-selected. Have a look at this blog post. Count-selected is described at the bottom of the post.

0 Kudos
WengNg
by
New Contributor III

Hi Ismael,

Thanks for the reply. The link to the blog post shows the use of the count-selected formula using the relevant column. What I want to do is add a constraint which does not let the user select more than the number of options in a select_multiple question (i.e. Returns an error message if user selects too many options)

I tried using the count-selected formula in the constraint column but it doesn't seem to work (my formula was Count-selected(.) in the Constraint column. 

I also tried  calculating the number of selected options by using the Count-selected (${question}) formula and then passing the value to the Constraint column but that didn't work as well.

Thanks ,

Weng

0 Kudos
IsmaelChivite
Esri Notable Contributor

May be the attached XLSFile will help. Note that the syntax of the expression is exactly the same, regardless of it  being in used for the constraint or relevant expression. For example:

count-selected(${colors})<3

WengNg
by
New Contributor III

Hi Ismael,

Thanks for getting back to me on this. The formula above works once I completed all required inputs and validated them.

I might have already used the correct formula all long but thought that the constraint check will force the pop-up when the user enters an invalid input.

Is there a way that the constraint mechanism checks the input as a user enters it instead of checking it at the very end of the form? 

It would be frustrating if the user has entered everything only to find that there is an error with one of the questions and the user would have to scroll through the entire form to modify the input.

Thanks,

Weng

0 Kudos
CustomerPortal
New Contributor

Weng,

I agree, it will be great to have an at selection notification, but in the meantime consider adding a "hint" to warn the user that they are not allowed to select more than X number of options.

Marius

0 Kudos