Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

No duplicates for 4 or more subquestions

More
5 years 10 months ago #190179 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.
The topic has been locked.
More
5 years 10 months ago #190181 by tpartner
What LimeSurvey version?

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.
More
5 years 10 months ago - 5 years 10 months ago #190183 by PaulMRFGR
Version 2.05+

I've attached a .lss

Thanks :)

File Attachment:

File Name: limesurvey...7661.lss
File Size:27.93 KB
Last edit: 5 years 10 months ago by PaulMRFGR.
The topic has been locked.
More
5 years 10 months ago - 5 years 10 months ago #190210 by tpartner
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.

- www.limesurvey.org/manual/Expression_Man...#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:

File Attachment:

File Name: limesurvey...7661.lss
File Size:29.98 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 10 months ago by tpartner.
The topic has been locked.
More
5 years 10 months ago #190233 by PaulMRFGR
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.
The topic has been locked.
More
5 years 10 months ago #190237 by jelo

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.

Being a novice wouldn't stop you from just trying it with <4, right?

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.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose