Actions

QS

Array filter: Difference between revisions

From LimeSurvey Manual

m (typo: missing verb)
mNo edit summary
Line 10: Line 10:


<!--T:24-->
<!--T:24-->
The Array filter advanced settings allow you to use any multiple choice question to select or set which responses display in a subsequent list, array or multiple choice question.
The Array filter setting allows you to use any multiple choice question to select or set which responses display in a subsequent list, array or multiple choice question.


<!--T:25-->
<!--T:25-->
<div class="simplebox">Starting in 1.92, subsequent questions can be filtered on any array question types, including:
<div class="simplebox">The subsequent questions can be filtered on any array question type, including:
*Multiple choice
*Multiple choice
*Multiple choice with comments
*Multiple choice with comments
Line 29: Line 29:


<!--T:28-->
<!--T:28-->
'''To set a filter'''
'''How to set a filter'''


<!--T:29-->
<!--T:29-->
Enter the question code of a multiple options question to use as the source information into the setting for array filter. For example, if your source multiple option question code is "Q1" enter "Q1" into either the 'Array Filter' input or the 'Array Filter Exclusion' input in the '''advanced settings''' of the question you want to filter. Only answer options that are selected in question Q1 will be visible in the array_filter-ed question.
To set a filter, enter the question code of a multiple options question in the array filter box. This will be used as the source of information for our current question which retrieves the selected answers from the previous questions and use them as answer options. For example, if your source multiple option question code is "Q1", enter "Q1" into the 'Array Filter' box to start the filtering process of the answers. Only the answer options that are selected in question Q1 will be visible in the array_filter-ed question.


<!--T:30-->
<div class="simplebox">If you wish more questions to be filtered via this option, type the question codes in the box separated by semicolons (;). </div>
<div class="simplebox">Starting in 1.92, you can enter multiple array_filter options for a single question, separated by semicolons</div>
 
<!--T:31-->
Array filter question settings ''require'' the questions being used to have exactly matching lists of answers. If the questions do not have exactly the same set of answers and codes, then the filters will break.
 
<!--T:32-->
<div class="simplebox">Starting in 1.92, if Q2 has sub-questions that are not present in Q1, they will always be displayed rather than breaking the filters.</div>


<!--T:33-->
<!--T:33-->
Line 47: Line 40:


<!--T:34-->
<!--T:34-->
The Array filter will cascade &ndash; that is you can select a question which filters another question, which filters another question, and so on.
The selected options can be displayed in cascade. This means that you can select a question which filters another question, which filters another question, and so on.


<!--T:35-->
<!--T:35-->
'''Array filter example'''
'''Array filter example'''


<!--T:36-->
Let's take at the following example to better understand the power of this setting.
Ticking items &lsquo;One&rsquo;, &lsquo;Three&rsquo; and &lsquo;Four&rsquo; in the first question results in the entries 'One', 'Three' and 'Four' displaying in the subsequent question which uses array filter
 
<!--T:37-->
Multi option question
 
<!--T:38-->
Code:Q1
 
<!--T:39-->
Question: Which animals do you like?
 
<!--T:40-->
1 Cat


<!--T:41-->
In the first image, we have the following question and answers:
2 Dog


<!--T:42-->
[[File:]]
3 Zebra


<!--T:43-->
Array 5 Point Choice Question
<!--T:44-->
Code:Q2
<!--T:45-->
Question: Rate these animals on a scale of 1 to 5, where 1 is ''I like them a little'' and 5 is ''I like them a lot''


<!--T:46-->
<!--T:46-->
'''Array filter example 2 - Using Multiple Short Text'''
'''Array filter example 2 - Using Multiple Short Text'''
<!--T:47-->
<div class="simplebox">Note: This features is available starting in version 1.92</div>


<!--T:48-->
<!--T:48-->
Line 105: Line 72:
<!--T:53-->
<!--T:53-->
[[Media:ls2_cascading_array_filter.lss|ls2_cascading_array_filter.lss]]
[[Media:ls2_cascading_array_filter.lss|ls2_cascading_array_filter.lss]]
<!--T:54-->
</onlyinclude>
</onlyinclude>


<!--T:55-->
<!--T:55-->
[[Category:Question Settings]][[Category:Advanced Question Settings]]
[[Category:Question Settings]][[Category:Logic Question Settings]]


</translate>
</translate>

Revision as of 14:46, 19 February 2018


Array filter (array_filter)

Description

The Array filter setting allows you to use any multiple choice question to select or set which responses display in a subsequent list, array or multiple choice question.

The subsequent questions can be filtered on any array question type, including:
  • Multiple choice
  • Multiple choice with comments
  • Multiple short text
  • Multiple numeric
  • Array (5 point, 10 point, Yes/No/Unknown, Increase/Same/Decrease, Column)
  • Array (Dual Scale, Text, Numbers)
  • Ranking

Furthermore, each of these types of questions can be filtered.

The only exception is Array (Column), which can filter other questions, but can not itself be filtered.

How to set a filter

To set a filter, enter the question code of a multiple options question in the array filter box. This will be used as the source of information for our current question which retrieves the selected answers from the previous questions and use them as answer options. For example, if your source multiple option question code is "Q1", enter "Q1" into the 'Array Filter' box to start the filtering process of the answers. Only the answer options that are selected in question Q1 will be visible in the array_filter-ed question.

If you wish more questions to be filtered via this option, type the question codes in the box separated by semicolons (;).

Cascading

The selected options can be displayed in cascade. This means that you can select a question which filters another question, which filters another question, and so on.

Array filter example

Let's take at the following example to better understand the power of this setting.

In the first image, we have the following question and answers:

[[File:]]


Array filter example 2 - Using Multiple Short Text

Here is the Limesurvey Group file for the above demo

limesurvey_group_32.lsg

Array filter example 3 - Cascading Array Filters

This sample survey shows use of array_filter, array_filter_exclude, and exclude_all_others, plus cascading array filters.

ls2_cascading_array_filter.lss