Professional > Interview scripting > Writing interview scripts > Logical expressions > Checking categorical responses > At least one of the specified responses chosen
 
At least one of the specified responses chosen
There are two ways of testing whether at least one response in a set was chosen, as in, did the respondent choose at least one weekend day from the response list, or, does the respondent play tennis, squash, badminton, and/or table tennis, but not all four sports. You can use the < or <= operators or the ContainsAny function.
At least one specified response and no others
To test whether the respondent chose at least one of the specified responses and no others, type either:
Qname <= {Resp1, Resp2, ... Respn}
or:
Qname.ContainsAny({Resp1, Resp2, ... Respn}, true)
where:
Qname is the name of the question whose response you want to check.
Resp1 to Respn are the names of the responses you want to check for.
(With ContainsAny, the true parameter is passed to the function when it is executed, and is the setting to be applied to the internal boolean variable, exactly. If the variable is True, the function tests for exactly the listed values and no others; if it is False, the function just tests for the presence of all the listed values. See ContainsAny for more information.
In both cases, the expression is True if the respondent chooses any of the specified answers at the named question and no others. For example, if the question is defined as:
DaysVisit "On which days do you normally visit the gym?"
categorical [1..7]
{
Monday, Tuesday, Wednesday, Thursday,
Friday, Saturday, Sunday
};
the expressions:
DaysVisit <= {Saturday, Sunday}
DaysVisit.ContainsAny({Saturday, Sunday}, true)
are True for all respondents who go to the gym at the weekend only; that is, on Saturday only, on Sunday only, or on both Saturday and Sunday. The expressions are False for people who go to the gym on any weekday even if they also go at the weekend.
At least one specified response with or without others
To test whether the respondent chose any of the specified responses with or without others, type:
Qname.ContainsAny({Resp1, Resp2, ... Respn})
For example, to check whether the respondent visits the gym at the weekend, regardless of any visits during the week, you might type either of the following:
DaysVisit.ContainsAny({Saturday, Sunday})
This expression is True for respondents choosing Saturday, Sunday, or both, with or without a weekday. The expression is False for anyone who does not got to the gym at the weekend.
Note If a question has no answer because it was never asked, ContainsAny returns False. An na response does not count as none, whether chosen specifically by the respondent or automatically because MustAnswer is False.
Some but not all specified responses with no others
You can check whether some but not all of the specified responses are chosen, without any other responses:
Qname < {Resp1, Resp2, ... Respn}
The expression:
DaysVisit < {Saturday, Sunday, Monday}
is True if the respondent goes to the gym on one or two of the specified days, but not on all three, and also not on any other days of the week. In other words, it is True for people who go on Saturday, Sunday, or Monday only, or who go on Saturday and Sunday, or on Saturday and Monday, or on Sunday and Monday only. The expression is False for anyone who goes to the gym on Saturday, Sunday, and Monday, or on any other day or days of the week.
Not just all the specified responses
You can also specify a test that returns True if none, or some but not all, of the listed responses are chosen, with or without other answers. In other words, you want to reject answers that contain the listed responses and nothing else. To do this, type:
Qname<> {Resp1, Resp2, ... Respn}
For example:
DaysVisit <> {Saturday, Sunday}
is False for anyone who goes to the gym on both Saturday and Sunday and not on any other day. It is True for everyone else; that is, for people who go only during the week, and for people who go on Friday and Saturday, and for people who go on Friday, Saturday, and Sunday.
See also
Checking categorical responses