It is very common to filter answer lists, scales and loops based on answers to previous questions. There are two types of filters:
- Masks based on sets of codes, which are used in "code masks" of single, multi, ranking, open text list, numerical list, grid, 3D grid questions and loops and "scale masks" of grids.
- "Column masks", which are used in 3D grids to filter the columns and are based on true/false expressions, just like conditions.
Code Masks and Scale Masks
Code masks are used to filter answer lists of 3D grids, grids, single, multi, ranking, open text list and numeric list questions, and to define the iterations that are to run in a loop. In the code mask field in properties of a question or a loop you may use a JScript .NET expression that evaluates to a set of codes. The answer list (or loop member list) will be filtered based on the set of codes in the code mask field.
Scale masks are used to filter scale lists of grid questions. Use the scale mask field in the properties of a grid question to enter a JScript .NET expression that evaluates to a set of codes. The scale list will be filtered based on this set of codes.
Filtering a Single Question Based on Answers to a Multi
Assume you have a questionnaire that uses a list called "Cars".
Figure 1 - Cars list
The list is used in two questions: First you have a multi question q2 which asks what cars you have tested, and then a 3D grid question g5 with a single question q3 which asks what car you did like most of the ones you tested, and a grid question q4 which asks you to rate the driving experience of the car.
Now, in the 3D grid question g5 you want just the cars answered in q2 to show. This can be achieved with a code mask with the following code:
f("q2")that will return a set with the codes of the answers to q2. The answer list of the 3D grid g5 will be filtered so that only the answers with these codes will be displayed.
Figure 2 - Masking tab
When the question q3 is displayed to the respondent, it will only show the cars answered in q2.
Column and Question Masks
Column Masks are used for filtering columns in a 3D grid. If you want to dynamically exclude a column (a question element in a 3D grid), use this field to create a JScript .NET expression that evaluates to true or false. The column is then displayed if the result is true, and is not displayed if the result is false. If you leave the field empty, the column is always displayed.
Question Masks are similar to Column Masks, but are used to filter an entire question. This can be useful when you want a group of questions to appear on the same page but one or more of them should not always be displayed. Before a condition a page break is automatically inserted, but for a question mask there will be no extra page break.
Excluding a Column (Question) in a 3D Grid
Let us say that in the 3D grid question from the previous example, we do not want inexperienced drivers (18-25 years) to answer question q4 – driving experience.
In the column mask field of question q4 we use the following code:
f('q2') != '2'to exclude the question from the 3D grid whenever the respondent is in the age group 18-25. (The symbol "!=" means "not equal to".)
Figure 3 - Excluding a question from the 3D grid