Welcome to the LimeSurvey Community Forum

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

count options marked in a multiple-choice question

  • josegovia
  • josegovia's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 10 months ago #169394 by josegovia
I would like to be able to count how many options a multiple-choice question is marked and use them in a relevant group equation.

For example:

Q1 (multiple-choice question)

Opt1 --- X
Opt2 --- X
Opt3

In the example the question Q1 has marked the response options Opt1 and OPT2 and relevant equation for a group of questions I would like to do is:

If Q1 has more than one option checked and Opt1 == "Y" the group is shown.

Thank you very much.


José
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #169395 by tpartner
Try:

Code:
count(that.Q1) > 1 && Q1_Opt1 == 'Y'

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: josegovia
The topic has been locked.
  • josegovia
  • josegovia's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 10 months ago #169396 by josegovia
Thank you very much for your quick response.

Now I would like to assign a value to a radio list type response. That is, the value will be marked in the question depending on the relevant equation.

For example, the radio-list-type question is Q2

And the response options are:

V1
V2
V3
V4

Following with the previous example:

If count (that.Q1)> 1 && Q1_Opt1 == 'Y' then Q2 = V2
If count (that.Q1)> 1 && Q1_Opt2 == 'Y' then Q2 = V3

How can I write that?

And also, where do I have to put that code? In the relevant equation of the question?

Thank you very much
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago - 5 years 10 months ago #169428 by tpartner
Please refer to the manual - manual.limesurvey.org/Expression_Manager..._Assignment_Operator

So, in you case, the assignment equation would be:
Code:
{Q2 = if(count(that.Q1) > 1 && Q1_Opt1 == 'Y', 'V2', if(count(that.Q1) > 1 && Q1_Opt2 == 'Y', 'V3', ''))}

That would be placed in a hidden (via CSS) equation type question directly following Q2.

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.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #169429 by Joffm
Just, to add:
Why did you start a new thread for this last question?

Now Denis and I answered it in the other thread, Tony here.

So it's confusing.

Joffm

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

Lime-years ahead

Online-surveys for every purse and purpose