Contraint for select multiple

624
5
Jump to solution
01-09-2023 03:22 PM
AlexDale2
New Contributor II

I have a select multiple question that has the following options:

red, black, blue, orange, unknown, refused

If someone selects unknown and/or refused,  I want them to not be able to select red, black, blue, orange.

currently I have this:

not(selected(.,'refused') or selected(.,'unknown') and (selected(.,'red') or selected(.,'black') or selected(.,'blue') or selected(.,'orange')))

 

It seemed to work fine, but I now noticed if you select refuse alone it will throw my contstraint message.

Any input?

0 Kudos
1 Solution

Accepted Solutions
ChristopherCounsell
MVP Regular Contributor
not((selected(.,'refused') or selected(.,'unknown')) and
(count-selected(${currentfield})>1))

View solution in original post

5 Replies
ChristopherCounsell
MVP Regular Contributor

Try using the count selected function? if you pick X or Y, count selection should not be greater than one. e.g. update this:

not((selected(.,'refused)) and (count-selected(${currentfield})>1))

 

AlexDale2
New Contributor II

I understand that can work. However, I want the logic to be the same if they select 'unknown'.

ChristopherCounsell
MVP Regular Contributor
not((selected(.,'refused') or selected(.,'unknown')) and
(count-selected(${currentfield})>1))
AlexDale2
New Contributor II

Thank you @ChristopherCounsell! That worked, I was missing the second parentheses around selected and unknown.

I appreciate your help and time.

ChristopherCounsell
MVP Regular Contributor

Thanks and sorry I forgot to include the 'or' statement in the original answer 😄

Would definitely recommend count-selected, or other ways (string length limits) instead of multiple or statements. Faster and makes it easier to accommodate additional values being added to the list down the track.

Please mark the answer as correct so I can gain those sweet internet points 🙂