intersection( array1, array2 )
Returns only those elements that appear in all of the given arrays.
Keyword | Type | Description |
---|---|---|
|
Any Type Array |
Array to intersect. |
|
Any Type Array |
Array to intersect. |
Any Type Array, matching the type of the inputs
intersection({1, 2, 3, 4}, {3, 4, 5, 6})
returns an array with 3, 4
Values are matched case sensitively:
intersection({"a", "b", "A"}, {"a", "c"})
returns an array with a
To match items case insensitively, use the lower()
function on both inputs.
A value is returned for each match:
intersection({"a", "b", "a"}, {"a"})
returns an array with a, a
intersection({"a"}, {1})
returns the following error message: Invalid types, can only act on data of the same type
.
Use either the conversion functions or the cast()
function to convert to the appropriate type.
When one of the arrays is empty, or no common values are found, an empty array of the same type as the inputs is returned:
intersection({1}, tointeger({}))
returns an empty integer array.
intersection({"a"}, {"b"})
returns an empty text array.
Null values in the array are matched and returned:
intersection({1, null, 3}, {1, null, 4})
returns an array with 1, <null>
An unlimited number of arrays can be compared, and the values common to all of them are returned:
intersection({1, 2}, {2, 3}, {2, 4})
returns an array with 2
Scalar inputs are cast to arrays:
intersection(1, 1)
returns an array with 1
Feature | Compatibility | Note |
---|---|---|
Portals | Compatible | |
Offline Mobile | Compatible | |
Sync-Time Custom Record Fields | Compatible | Can be used to create a custom record field that only evaluates at sync time. |
Real-Time Custom Record Fields | Incompatible | |
Process Reports | Compatible | |
Process Events | Compatible |
intersection() Function