Unselecting a select_multiple value based on selection of another value

726
2
03-29-2019 10:15 AM
PeterDalrymple
Occasional Contributor

Is there a way in Survey123 to unselect a select_multiple value based upon the user selecting another value from the same select_multiple question? I have a select_multiple question that defaults to 'None', but I would like 'None' to become unselectable and/or unselected if a user selects any other value from the list. I have tried a number of expressions in the default column, but to no avail. Are there any suggestions as to the best way to achieve this behavior? Is there default column the best place to try to achieve this?

Thanks!

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

There is a way to count how many choices are picked like count-selected(question).     

How about in the constraint if(selected(None), count-selected(question)<1,1) type of If.  So saying if None is selected and there is more than one selection there is an issue.  If none is not selected then then 1 just lets it go.

0 Kudos
PeterDalrymple
Occasional Contributor

Thanks Doug Browning. I couldn't quite get that to work for me very quickly, but I'd probably chalk that up to user error and lack of time on my part. I did end up using a formula from James Tedrick in the comments of Multiple Choice Constraint - A List of values and putting it into a nested if statement:

if(selected(${Question},'Answer1'), not(selected(${Question},'None')), if(selected(${Question},'Answer2'), not(selected(${Question},'None')),true)) 

This nested if statement goes on and on with 6 possible choices so it's not very elegant, but it gets the job done.

It also doesn't actually unselect the 'None' option, but it does prevent the user from selecting "None" in conjunction with the other possible values. Another downside is that it doesn't evaluate the expression until the user submits the form.

Would love to hear some better or different ways to do this.

0 Kudos