UNION Function
The UNION function creates a single list of unique values by first checking for and discarding any duplicate unanswered values in the first list the function takes as a parameter, and then checking for and discarding any duplicate or unanswered values in the second list it takes as its second parameter. The function also compares the unique values from both lists to each other and discards any duplicate values between the two before adding the unique values from both lists to a new result list.
The two lists the UNION function takes as parameters must be of the same value type, and may be of any valid list value. The result list is the same value type as the lists you add as parameters. Typical sources for the parameter lists include:
Function name | UNION |
Usage model | UNION (l1:LIST, l2:LIST) |
Parameters | The UNION functions requires you to replace the l1 and l2 models with two parameters: |
l1: LIST |
The UNION function takes a list (the answer values from a Multi Select variable, repeated dialog, or Table variable) as its first parameter. The answer type of this first parameter must match the answer type of the second parameter. |
l2: LIST |
The UNION function takes a list (the answer values from a Multi Select variable, repeated dialog, or Table variable) as its second parameter. The answer type of this second parameter must match the answer type of the first parameter. |
Result | A list whose answer type matches the answer type of the two inputs (parameters). |
Example
Consider a situation where you have two Multi Select variables that represent states in which property is owned, (PropertyType1 and PropertyType2), and you want to combine the two lists to form a single list of states where property of types 1 and 2 are owned, and then store this list in a Multi Select variable called PropertyTypes1and2. Your code might look something like this:
SET PropertyTypes1and2 TO UNION(PropertyType1, PropertyType2)
The result of this would be a list of states selected in either PropertyType1 or PropertyType2 while not including any state twice in the new list even though a user may select the same state in PropertyTyp1 and PropertyType2.