Survey Tabulation > Advanced expressions > UNICOM Intelligence function library > Categorical functions > ContainsAny
 
ContainsAny
Identifies whether a category list contains one or more categories in a given list.
Syntax
ContainsAny(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 False.
Exactly
Type: Type: Boolean
Optional. If True, the function returns False if Val 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 Val, even if Val contains other categories.
(return)
Type: Type: Boolean
True if Val contains the categories as specified, 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.
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 will select respondents who chose either one or both of the two categories regardless of whether they chose any additional categories. For example, it will select 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
Categorical functions