ContainsAll
Identifies whether a category list contains all of the categories in a given list.
Syntax
ContainsAll(Val, Answers [, Exactly])
Parameters
Val
Type: Categorical
Categorical value.
Answers
Type: None
Variant value of type Categorical or Text, specifying a set of categories to look for in Val. If Answers is empty, the function returns True, unless Exactly is True and Val is not empty.
Exactly
Type: Boolean
Optional. If True, the function returns True only if Val contains all of the categories in Answers and no others. If Exactly is omitted or False, the function returns True if all of the categories in Answers are in Val, even if Val contains other categories.
(return)
Type: Boolean
True if Val contains all of the categories in Answers, otherwise False.
Remarks
If the current value is NULL, Val is an empty Categorical value ({}) and the return value is False. If Answers is NULL, the return value is False.
This function is equivalent to the >= comparison operator (see
Comparison operators) for categorical values, except that the NULL behavior is different. However, using the >= operator is generally faster than using the ContainsAll function.
Examples
Function call
|
Response
|
Filter
|
Result
|
ContainsAll(Response, Filter)
|
{1,2,3,4,5,6,7,8,9,10,11,12,13, 14,15}
|
{2,6,4,8,11,7}
|
True
|
Response.ContainsAll(Filter, True)
|
{1,2,3,4,5,6,7,8,9,10,11,12,13, 14,15}
|
{2,6,4,8,11,7}
|
False
|
Response.ContainsAll(Filter, True)
|
{6,7,11,4,8,2}
|
{2,6,4,8,11,7}
|
True
|
Response.ContainsAll(Filter)
|
{1,2,3,4,5,6,7,8,9,10,11,12,13, 14,15}
|
{2,6,4,8,11,7,20}
|
False
|
Like
ContainsAny and
ContainsSome, ContainsAll is typically used to filter multiple response data. The Museum sample data set contains a multiple response variable called
remember, which records the galleries that respondents remember viewing. You could use the following example to create a filter to select respondents who chose the
Fossils and
Dinosaurs categories in response to the question:
remember.ContainsAll({fossils, dinosaurs})
This filter will select respondents who chose both Fossils and Dinosaurs regardless of whether they chose any additional categories. To restrict the filter to respondents who chose Fossils and Dinosaurs and no other categories, set Exactly to True:
remember.ContainsAll({fossils, dinosaurs}, True)
More examples
To define a filter in an SQL query, see
Basic SQL queries.
To define a filter for a weighting calculation in mrScriptBasic, see
More on target weighting.
See also