Survey Tabulation > Advanced expressions > UNICOM Intelligence function library > Categorical functions > XUnion
 
XUnion
Returns the exclusive union of two category lists: that is, it returns all of the categories that are in either one of the category lists, but not in both.
Syntax
XUnion(Val, Answers)
Parameters
Val
Type: Categorical
Categorical value.
Answers
Type: None
Variant value of type Categorical or Text, specifying a set of categories.
(return)
Type: Categorical
Set of categories that are in either Val or Answers but not in both.
Remarks
If the current value is NULL, Val is an empty Categorical value ({}) and the return value is Answers. If Answers is NULL, the return value is Val.
This function is equivalent to the / arithmetic operator (see Arithmetic operators) for Categorical values, except that it can operate on named categories and the NULL behavior is different. However, using the / operator is generally faster than using the XUnion function.
Examples
Function call
Q1
Q2
Result
XUnion(Q1, Q2)
{3,5,9,10,23,5,6}
{5,16,4,10}
{3,9,23,6,16,4}
Q1.XUnion(Q2)
{3,5,9,}
{5,3,9}
{}
Like the Difference and Intersection functions, XUnion is useful when categorical variables have identical or overlapping category lists. For example the biology and education variables have identical response lists. In the following example, XUnion is used to return any categories that are in either one of the category lists, but not in both and the >= operator tests whether the result contains the Yes category. For example, you could use this expression to select respondents who chose the Yes category in response to either one of the questions, but not to both.
XUnion(biology, education) >= {yes}
See also
Categorical functions