Scripting > UNICOM Intelligence Function Library > Categorical functions > Union
 
Union
Returns the union of two or more category lists--that is, it returns all of the categories that are in any one or more of the category lists.
Syntax
Union(Val [, Vals, ...])
Parameters
Val
Type: Categorical
Categorical value.
Vals
Type: None
One or more variant values of type Categorical or Text. Each value specifies a set of categories.
(return)
Type: Categorical
All of the categories in Val, followed by any other categories that are in Vals.
Remarks
If an item in Vals is NULL, the item is ignored. If the current value is NULL, Val is an empty Categorical value ({}) and the return value is the union of all non-NULL items in Vals.
This function is equivalent to the Addition (+) operator+ for Categorical values, except that Union can operate on named categories and the NULL behavior is different. However, using the + operator is generally faster than using the Union function.
Examples
Function call
Q1
Q2
Result
Union(Q1, Q2)
{5,1,6,3,2,4}
{3,6,7,5}
{5,1,6,3,2,4,7}
Q1.Union(Q2)
{4,2,9,6,1,7}
{}
{4,2,9,6,1,7}
Function call
Q1
Q2
Q3
Result
Q1.Union(Q2, Q3)
{6,8,2,3}
{3,4,6}
{1,7,8}
{6,8,2,3,4,1,7}
Union(Q1, Q2, Q3)
{6,8,2,3}
{3,4,6}
NULL
{6,8,2,3,4}
The following example uses Union to combine the results of two single response categorical variables that have similar category lists and tests whether the result includes the Yes category. For example, you could use this example to select respondents who chose Yes in response to at least one of the questions.
Union(biology, education) >= {yes}
See also
Merge
Categorical functions