I don't want respondents selecting any of the same choices for Question 1 and Question 2 (both of which are select-multiple from the same list of choices). In theory I would use a cascading select however that's only possible for select-one questions. Therefore, I'd created a question (Q3) to check to see if responses to Q1 and Q2 are the same and provide a warning as necessary.
Q3
Calculation: if(${Q1} = ${Q2}, "same", "different")
Constraint: .!="same"
Calculation Message: Response to Q1 and Q2 cannot be the same.
First problem:
Before I answer either Q1 or Q2, Q3 defaults to "same". When I start selecting responses to Q1, Q3 updates to "different". When I select responses to Q2 however, Q3 does not update/change - regardless of my selection to Q2. It seems to only calculate once. How do I get the Q3 calculation to auto refresh when response to Q1 or Q2 are made/change?
Second problem:
The calculation above should only look to see if Q1 and Q2 are an exact match. I actually need it to identify if any of the same responses are checked. For example, if answers to Q1 are A1, A2, A4 and answers to Q2 are A1, A3 I need my calculation to be "same". I think adding in a regex is the way to do this but how to I specify this?
James Tedrick? Ismael Chivite? Anyone else have a solution to try?
Solved! Go to Solution.
Hi Alicia,
This is somewhat difficult because select_multiple values store the choices in the order they were input. For example you could have a situation of:
Q1: A,B,C
Q2: B,C,A
This would be regarded as different with your criteria, even though the same choices have been selected. What you instead need to do is check, choice by choice, whether a choice is selected in both questions. This can be done by using the selected() function. selected() returns True if a choice is selected; combining the selected() function for the 2 questions together:
selected(${q1},'choice1') and selected(${q2},'choice1')
We will get a True value only if both q1 & q2 have 'choice1' selected. We get flip that to False (which we need for a constraint to work properly) by using the not() function:
not(selected(${q1},'choice1') and selected(${q2},'choice1'))
When used as a constraint calculation, this will now throw an error if choice1 has been selected in both questions. To check all choices, we need to join copies of this for each choice together with 'and' statements, so that one of them being False means the entire statement is False:
not(selected(${q1},'choice1') and selected(${q2},'choice1')) and not(selected(${q1},'choice2') and selected(${q2},'choice2')) and not(selected(${q1},'choice3') and selected(${q2},'choice3')) ...
See the attached sample
Hi Alicia,
This is somewhat difficult because select_multiple values store the choices in the order they were input. For example you could have a situation of:
Q1: A,B,C
Q2: B,C,A
This would be regarded as different with your criteria, even though the same choices have been selected. What you instead need to do is check, choice by choice, whether a choice is selected in both questions. This can be done by using the selected() function. selected() returns True if a choice is selected; combining the selected() function for the 2 questions together:
selected(${q1},'choice1') and selected(${q2},'choice1')
We will get a True value only if both q1 & q2 have 'choice1' selected. We get flip that to False (which we need for a constraint to work properly) by using the not() function:
not(selected(${q1},'choice1') and selected(${q2},'choice1'))
When used as a constraint calculation, this will now throw an error if choice1 has been selected in both questions. To check all choices, we need to join copies of this for each choice together with 'and' statements, so that one of them being False means the entire statement is False:
not(selected(${q1},'choice1') and selected(${q2},'choice1')) and not(selected(${q1},'choice2') and selected(${q2},'choice2')) and not(selected(${q1},'choice3') and selected(${q2},'choice3')) ...
See the attached sample