- Posts: 51
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
No duplicates for 4 or more subquestions
- PaulMRFGR
- Topic Author
- Offline
- Senior Member
Less
More
4 years 5 months ago #190179
by PaulMRFGR
No duplicates for 4 or more subquestions was created by PaulMRFGR
Hi there,
We have a question where respondents must select a price on a scale for each of 8 subquestions. Respondents should be unable to select the same price for 4 or more of the subquestions e.g. they can't select £10 for 4+ of the subquestions.
How can we go about doing this?
Thank you.
We have a question where respondents must select a price on a scale for each of 8 subquestions. Respondents should be unable to select the same price for 4 or more of the subquestions e.g. they can't select £10 for 4+ of the subquestions.
How can we go about doing this?
Thank you.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
4 years 5 months ago #190181
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic No duplicates for 4 or more subquestions
What LimeSurvey version?
Can you attach a small sample survey (.lss file) containing only that question?
Can you attach a small sample survey (.lss file) containing only that question?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- PaulMRFGR
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 51
- Thank you received: 0
4 years 5 months ago - 4 years 5 months ago #190183
by PaulMRFGR
Replied by PaulMRFGR on topic No duplicates for 4 or more subquestions
Version 2.05+
I've attached a .lss
Thanks
I've attached a .lss
Thanks
Attachments:
Last edit: 4 years 5 months ago by PaulMRFGR.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
4 years 5 months ago - 4 years 5 months ago #190210
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic No duplicates for 4 or more subquestions
For the benefit of others, you are using an array type question with question code "Combinations" and 35 answers with codes 1-35.
In this case, you can use the Expression Manager countif() function to count the number of selections of each answer.
- manual.limesurvey.org/Expression_Manager#Access_to_Functions
So, something like this in the question validation equation:
Here is your sample survey back with that change:
In this case, you can use the Expression Manager countif() function to count the number of selections of each answer.
- manual.limesurvey.org/Expression_Manager#Access_to_Functions
So, something like this in the question validation equation:
Code:
countif('1', that.Combinations) < 5 AND countif('2', that.Combinations) < 5 AND countif('3', that.Combinations) < 5 AND countif('4', that.Combinations) < 5 AND ... AND countif('31', that.Combinations) < 5 AND countif('32', that.Combinations) < 5 AND countif('33', that.Combinations) < 5 AND countif('34', that.Combinations) < 5 AND countif('35', that.Combinations) < 5
Here is your sample survey back with that change:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 4 years 5 months ago by tpartner.
The topic has been locked.
- PaulMRFGR
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 51
- Thank you received: 0
4 years 5 months ago #190233
by PaulMRFGR
Replied by PaulMRFGR on topic No duplicates for 4 or more subquestions
Amazing! Thank you - this worked. Just quickly, if we wanted to change it to a maximum of 3 equal answers, how would we change the validation equation here?
Is it just a case of changing the '< 5' to '< 4'?
Again, as a complete novice to coding, I can only apologise for my ignorance.
Is it just a case of changing the '< 5' to '< 4'?
Again, as a complete novice to coding, I can only apologise for my ignorance.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
4 years 5 months ago #190237
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic No duplicates for 4 or more subquestions
Being a novice wouldn't stop you from just trying it with <4, right?PaulMRFGR wrote: Is it just a case of changing the '< 5' to '< 4'?
Again, as a complete novice to coding, I can only apologise for my ignorance.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: holch, tpartner
The topic has been locked.