Developer Documentation Library > UNICOM Intelligence Function Library > Categorical functions > ContainsAny
 
ContainsAny
Identifies whether a category list contains one or more categories in a given list.
Syntax
ContainsAny(<value>,<answer> [, <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 False.
<exactly>
Type: Boolean
(Optional.) If True, the function returns False if <value> contains any categories that are not in <answers>. If <exactly> is omitted or False, the function returns True if any of the categories in <answers> are in <value>, even if <value> contains other categories.
(return)
Type: Boolean
True if <value> contains the categories as specified, 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.
Examples
Function call
Response
Filter
Result
Response.ContainsAny(Filter)
{2,6,4,8,11,7}
{6,13}
True
Response.ContainsAny(Filter, True)
{2,6,4,8,11,7}
{6,13}
False
Response.ContainsAny(Filter, True)
{11,4,2,8,6,7}
{2,6,4,8,11,7}
True
ContainsAny(Answers, Filter)
{2,6,4,8,11,7}
{1}
False
Like ContainsAll and ContainsSome, ContainsAny 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 either or both of the Fossils and Dinosaurs categories in response to the question:
remember.ContainsAny({fossils, dinosaurs})
This filter selects respondents who chose either one or both of the two categories regardless of whether they chose any additional categories. For example, it selects respondents who chose any of the following:
The Fossils category only.
The Dinosaurs category only.
The Fossils and Dinosaurs categories only.
The Fossils category and any other category.
The Dinosaurs category and any other category.
To restrict the filter to respondents who chose either or both of the two specified categories and no others, set Exactly to True:
remember.ContainsAny({fossils, dinosaurs}, True)
More examples
To define an expression for a derived variable in Visual Basic, see Dynamically derived variables.
To define a filter for a table created using the Table Object Model (TOM), see Defining your first filter.
See also
ContainsAll
Categorical functions