Welcome to the LimeSurvey Community Forum

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

Filter answers of a question with the answer of another

  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 5 months ago #176306 by KompetenzZ
Hi,

I would like to filter answers of a question based on the answer of another question. Is it somehow possible to use this workaround for questions that are on the same page (and not on separate pages)?
manual.limesurvey.org/Workarounds:_Manip...he_answer_of_another

Cheers kompetenzz
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 5 months ago #176327 by holch
Like always: Which LS version are you running? The workaround you are posting is for very old version of LS and will most probably not work for newer versions anyway.

It is also important to know, which question types are involved. Newer versions of Limesurvey have sub question relevance, so for all questions that use sub questions (multiple choice, matrix/array, etc.) you can use subquestion relevance.

Depending on what you want to do you could also use the array filter feature.

But ideally you show a real life example as LSS file that outlines your exact problem.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 5 months ago #176331 by KompetenzZ
Hi,

Sorry, I am running LimeSurvey Version 3.14.11+180926.

The questions types "Radio (List)" and "Multiple choice" for questions that are on the same page are involved.

As far as I tested it, the array filter is not the right feature for me.

I made a survey with 4 question groups to show you the combinations between "Radio (List)" and "Multiple choice" that I am interested in (one question group for each combination) with some explanation in the question group description. See attachment.

File Attachment:

File Name: limesurvey...2353.lss
File Size:37 KB



Thank you

Cheers kompetenzz
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 5 months ago #176335 by holch
I had a quick look and what you are trying to do (at least in the first 2 groups) should be possible with subquestion relevance. However: I don't think it is a good solution to have these two questions that depend on each other on the same page, because your respondents will see subquestions appear and disappear, which I personally prefer to avoid, as it gives insights in the structure of the questionnaire and it might lead to respondents playing around, etc. If they don't see the dependencies, they generally don't search for it, but when they see it, some will start to tinker around.

OK, here to the solution of your problem:

Group 1: You need to put Q1==1 into the relevance equation of the subquestions 1, 2 and 3 for Q2. See attached LSS file. Tested and works, even with both questions on the same page.
However, what happens if someone says "no answer"? Shouldn't then the whole question Q2 be hidden? I would actually not offer "no answer" here at all.

Group 2: Here you are trying to hide those options in Q4, that have been chosen in Q3. This also can be solved by adding a relevance equation to the subquestion relevance. You basically need to check if each subquestion in Q3 has been ticked in order to hide the corresponding subquestion in Q4. This code does the trick for the first subquestion. the others need to be adapted accordingly (see attached LSS - tested and works):
Code:
Q3_1 != 'Y'

Group 3:
Would work similar to what we seen before, unfortunately the question type used does not offer subquestion relevance (because the question type does not have subquestions, but answer options). You might be able to do something with Javascript, but I am not sure how this would work. The only solution that comes to my mind right now is create two questions Q6, one with the first answer option, one without the first answer option and show them via question relevance, based on the fact if the first answer in Q5 was marked or not. Maybe someone else has a better idea.

Group 4:
Same problem as in Group 3. The question type used for Q8 does not allow subquestion relevance. You could again create the workaround mentioned above with two different questions and show one if one of the first 3 options in Q7 have been marked, if not, then show the other question.

Or, you could use a multipe answer question, and limit it to 1 answer. Not the cleanest approach, but works out of the box. Maybe someone else has a cleaner idea here.

How I miss answer option relevance... ;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 5 months ago #176350 by KompetenzZ
Thank you very much for your answer, holch.
This is a valid point that the respondents could tinker around. Maybe I could reorder the questions in such a way that they are not visible on the screen in a longer question group, so that they respondents do not notice that subquestions appear and disappear because they would have to scroll down to see it. Do you think the "Format: Question by question" is more appropriate than place some subquestions that will appear on the bottom of a (long) question group?
(I think placing the filtered answers questions to the top of a new question group with more than one question will not work because there might be too many of these filtered answers questions in my survey.)

Shure, I will remove the "no answer" option.

Now I recognized that the relevance equation is also available for subquestions, thanks.

Cheers kompetenzz
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 5 months ago #176480 by Joffm
Hi,

If you want to filter a singlepunch question on another singlepunch question,
like:
"Which country?"
"Which city? (only cities to be displayed in the selected country)

you can use this:

File Attachment:

File Name: limesurvey...1-08.lss
File Size:36 KB


It's always the same procedure.
By an equation you check a hidden multipunch question which you use as array filter for your singlepunch.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: KompetenzZ
The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 4 months ago #177181 by KompetenzZ
Hi,

I tried this filter procedure of a list (radio) answer on another list (radio) answer as explained by Joffm and it works.
But now my first question is a multiple choice question (instead of the list (radio) question) . In this situation the procedere described by Joffm doesn't seem to work. The answer options that are filtered show never up. Is there something wrong? A test survey (.lss) is attached.

These are the expressions in the equation question, whereby q1 is the multiple choice question:
{a2_1=if(q1_1 == 'Y')}

{a2_2=if(q1_1 == 'Y')}

{a2_3=if(q1_1 == 'Y')}

{a2_4=if(q1_2 == 'Y')}

{a2_5=if(q1_2 == 'Y')}

{a2_6=if(q1_2 == 'Y')}




File Attachment:

File Name: limesurvey...5533.lss
File Size:23 KB

Cheers kompetenzz
The topic has been locked.
  • KompetenzZ
  • KompetenzZ's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 4 months ago - 5 years 4 months ago #177197 by KompetenzZ
I am glad that I found the error myself :)
The following explanations are just for documentation:
If one has the combination of filtering answers "multiple choice -> single choice", then the expression in the equation question has to be different than the expression in "single choice -> single choice".

The if statement has always this structure:
if(<condition>,<text_if_true>,<text_if_false>)

In my previous post, I was not consistent with this structure. I just wrote in the if statement (with the new example question codes):
if(Q7_1=="Y")

Which means I only wrote the <condition> part. The other two parts have to be added:
if(Q7_1=="Y","Y","")

And together with the "=" the full expression is:
{Q8_1=if(Q7_1=="Y","Y","")}

This means that the answer of Q8_1 will be set to "Y" (ticked) if the answer of Q7_1 is "Y" (ticked).

If someone will need this procedure of filtering "radio (list)" answers based on "multiple choice" answers I made a test survey that is attached. However, keep in mind that this procedure only works if the "radio (list)" and the "multiple choice" are on different question group pages (or "Survey Settings -> General Settings -> Format: question by question" is activated).


File Attachment:

File Name: limesurvey...4162.lss
File Size:23 KB

Cheers kompetenzz
Last edit: 5 years 4 months ago by KompetenzZ.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose