ContainsAll
Identifies whether a category list contains all of the categories in a given list.
Syntax
ContainsAll(<value>, <answers> [, <exactly>])
Parameters
<value>
Type: Categorical
Categorical value.
<answers>
Type: None
Variant value of type Categorical or Text, specifying a set of categories to look for in <value>. If Answers is empty, the function returns True, unless <exactly> is True and <value> is not empty.
<exactly>
Type: Boolean
(Optional.) If True, the function returns True only if <value> 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 <value>, even if <value> contains other categories.
(return)
Type: Boolean
True if <value> contains all of the categories in Answers, otherwise False.
Notes
If the current value is NULL, <value> 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 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)
For an example of using ContainsAll:
▪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