Desktop User Guides > Professional > Interview scripting > Writing interview scripts > Logical expressions > Checking categorical responses > All the specified responses chosen
 
All the specified responses chosen
There are two ways of testing whether all responses in a set were chosen, as in, did the respondent choose product A and product B from the response list. You can use the =, >=, or > operators or the ContainsAll function.
All specified responses and no others
To test whether the respondent chose all the specified responses and no others, type either:
Qname = {Resp1, Resp2, ... Respn}
or:
Qname.ContainsAll({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. If you are using ContainsAll, you must name at least two responses.
(With ContainsAll, 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 ContainsAll for more information.)
In both cases, the expression is True if the respondent chooses all the specified answers at the named question and no others. For example, if the question is defined as:
Tried "Which of the test products did you try?"
    categorical [1..4]
{
  ProductA "Product A",
  ProductB "Product B",
  ProductC "Product C",
  ProductD "Product D"
};
the expressions:
Tried = {ProductA, ProductB}
Tried.ContainsAll({ProductA, ProductB}, true)
are True for all respondents who tried both products and no others. They are False for anyone who did not try both the named products, and for people who tried products A and B with one or both of products C or D.
All specified responses with or without others
If you want to test whether the respondent chose all the specified responses with or without others, type either:
Qname >= {Resp1, Resp2, ... Respn}
or:
Qname.ContainsAll({Resp1, Resp2, ... Respn})
For example:
Tried >= {ProductA, ProductB}
Tried.ContainsAll({ProductA, ProductB})
Both expression are True for respondents choosing products A and B with or without products C and D. The expressions are False for anyone who does not choose products A and B.
All specified responses and at least one other
The final possibility to is test whether the respondent chose all the specified responses with at least one other response. To do this, type either:
Qname > {Resp1, Resp2, ... Respn}
For example:
Tried > {ProductA, ProductB}
This expression is True if the respondent chooses products A and B with at least one of products C and D — that is, A, B, and C, or A, B, and D, or all four products.
See also
Checking categorical responses