Professional > Interview scripting > Writing interview scripts > Filtering questions and response lists > Filtering loops > Filtering the questions in a loop (ask some questions, but not others) > Asking different questions for different repetitions
 
Asking different questions for different repetitions
If you present the loop as a series of repeated pages rather than as a grid, you can use filtering to vary the questions for each repetition. For example, you could ask about hot drinks on weekdays and cold drinks at weekends. You cannot use filtering to do this if you present the questions in a grid. (There is an alternative method for grids which is discussed in Jagged grids.)
There are several things you need to do in order to present different questions for different repetitions, including some possible alterations or additions to the specification in the metadata section. However, let’s look at the filtering first.
Syntax
The code to define a filter for a specific repetition is:
LoopName.CategoryName.QuestionFilter = "Qnames"
Parameters
LoopName
The name of the loop.
CategoryName
The name of the repetition to be executed.
Qnames
The names of the questions to be asked for this repetition.
Parameters
The filters for the example are:
EatThisFood.Fruit.QuestionFilter = "Monday..Friday"
EatThisFood.Vegetables.QuestionFilter = "Monday..Friday"
EatThisFood.Salads.QuestionFilter = "Monday..Friday"
EatThisFood.Fish.QuestionFilter = "Saturday..Sunday"
EatThisFood.Meat.QuestionFilter = "Saturday..Sunday"
and you present the questions about each type of food on a separate page by typing:
EatThisFood[..].Ask()
When you ask questions in this way, it is important to place the general question text, or an explanation of what the questions are about, after the fields parameter in the loop definition, otherwise the respondent will just see boxes labeled with the days of the week. For example:
EatThisFood loop
{use FoodList}
fields "How many times did you eat {@EatThisFood} on ...?"
(
Monday long [0..10];
Tuesday long [0..10];
Wednesday long [0..10];
Thursday long [0..10];
Friday long [0..10];
Saturday long [0..10];
Sunday long [0..10];
) expand;
produces pages of the form:
Compare this illustration and the script snippets with the grid illustration and script shown earlier in this topic.
See also
Filtering the questions in a loop (ask some questions, but not others)