Welcome to the LimeSurvey Community Forum

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

limit answers in an array

  • etretout
  • etretout's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 1 month ago #160647 by etretout
limit answers in an array was created by etretout
Hi,

I would like to limit answers in an array

Example with the capture

I would to limit A to 2 answers and the same thing for B. The maximum answers for the array is 4

Could you help me ?

Thanks
Attachments:
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago - 7 years 1 month ago #160649 by Joffm
Replied by Joffm on topic limit answers in an array
Just count the answers of each column.

Read: www.limesurvey.org/manual/Expression_Man....27that.27_variables
and
[url=Implemented Functions]Implemented Functions[/url]

I used "countifop"


Then you do a question validation like (count of column A < 3) and (count of column B < 3)

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 7 years 1 month ago by Joffm.
The topic has been locked.
  • etretout
  • etretout's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 1 month ago #160651 by etretout
Replied by etretout on topic limit answers in an array
thks

i have to do a question validation like : count(question1.A1)<3 and count(question1.A2)<3
The topic has been locked.
  • etretout
  • etretout's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 1 month ago #160655 by etretout
Replied by etretout on topic limit answers in an array
thx

how countiftop works in my case ?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago - 7 years 1 month ago #160657 by Joffm
Replied by Joffm on topic limit answers in an array
{countifop("==","A1",self)} with A1 = code of answer option

It's obvious: You count the whole question if the option is "equal A1".
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 7 years 1 month ago by Joffm.
The topic has been locked.
  • etretout
  • etretout's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 1 month ago #160751 by etretout
Replied by etretout on topic limit answers in an array
ok thx

i would like to limit at 2 answers

i tried with : {countifop("<","A1",3)} but it doesn't work
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #160763 by Joffm
Replied by Joffm on topic limit answers in an array
Of course. this cannot work.

What do you do?
1. You compare with a text. What is smaller than "A1"? What is smaller than "etretout"?
Text you can only compare "equal or not equal".
Therefore I always pray: Do not use these silly default codes like "A1", "A2". Use numeric codes.

2. What is this "3". Here you enter the column or row or entire question you want to count.

Why did you try to change my formula?
{countifop("==","A1",self)} with A1 = code of answer option.
In the actual question ("self") it counts the amount of code A1 in all subquestions. To count the codes A2, you set {countifop("==","A2",self)}

And to limit your question you combine both in the question validation:
((countifop("==","A1",self)<3) and (countifop("==","A2",self)<3))


Still okay:


Too many in clolumn 2.


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose