Desktop User Guides > 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)
Filtering the questions in a loop (ask some questions, but not others)
You can filter the questions in a loop so that only some are presented to the respondent
Put the following statement in the routing section:
LoopName[..].QuestionFilter = "Questions"
The name of the loop.
The questions to be displayed. This can be either a comma-separated list of questions names or, if the questions are consecutive, a range of names defined as Qname1..QnameN.
FoodList define
Fruit, Vegetables, Salads, Fish, Meat, Bread,
Dairy "Dairy produce",
Pulses "Pulses/Nuts/Cereals",
PastaRice "Pasta/Rice"
TimesEaten "On the following days last week, how many times did
  you eat ... ?" loop
{use FoodList}
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];
) grid expand;
In this loop, the types of food are the answers (rows) and the days are the questions (columns). To restrict the grid to displaying weekend days only, place the following statement in the routing section:
TimesEaten[..].QuestionFilter = "Saturday, Sunday"
For a grid that displays weekdays only, type:
TimesEaten[..].QuestionFilter = "Monday..Friday"
In both examples, notice the use of [..] to show that the specification applies to all repetitions. Without this, the interviewing program assumes that the statement refers to repetitions rather than questions, and the interview will fail when it reads values that refer to questions. You can use this fact to your advantage if you want to filter on repetitions rather than questions. For example:
TimesEaten.QuestionFilter = "Fruit, Salads"
produces a grid with rows for fruit and salads only and columns for all days of the week. For more information on this aspect of loop filtering, see Filtering the repetitions of loops with categorical control lists.
See also
Filtering by repetition and question
Asking different questions for different repetitions
Filtering loops