I have a multiple choice question with three options, the third being neither. I want the survey to de-select the other(s) if neither is chosen or vice versa. I found the below code when using google but nothing happens when i use that.
not(selected(., 'option_c') and selected(., 'not_option_c'))
Hi @SeanWalsh
I was able to make it work with the following syntax:
It doesn't deselect as such but it will return invalid if the constraint fails
Hope this helps
That didn't do anything. Maybe I'm plugging in the wrong information? Also this goes in the constraint column correct?
not(selected(${form_d_foultime}, 'Neither') and count-selected(${form_d_foultime}) > 1) |
It should work in both the field app and web browser. May you share your xlsx form either in a reply or via direct message.
Thanks
@SeanWalsh You need to match the capitalization of your neither in the choice list, since the response would be 'neither', your statement looking for 'Neither' would never evaluate to False.
not(selected(${form_d_foultime}, 'neither') and count-selected(${form_d_foultime}) > 1)
Thanks
Automatically selecting/unselecting choices in a select_multiple, based on the user's selection, it not possible. This would involve a calculation in the select_multiple that uses select_multiple selection as an input. The XLSForm validator will flag this as a dependency cycle.
Logically, an expression like this would achieve what @SeanWalsh requested.
Unfortunately, this will return an XLSForm validation error.
As @Richard_Purkis suggested, one could put together an expression to validate the user input. That is, to make sure that if Neither is selected, no other options are.
This is one example:
Note that the expression is not in the calculation column. Instead, it is a constraint.
All in all, the post was a bit confusing because the title Multiple Choice Contstraint hinted that @SeanWalsh wanted to build a constraint, but then the description clarified that what was needed was a recalculation. In any event: You can get a constraint, but not recalculate the values.