set_difference()
Learn how to use the set_difference() function to create a difference set of all distinct values in the first array that aren’t in the other array inputs.
Returns a dynamic (JSON) array of the set of all distinct values that are in the first array but aren’t in other arrays - (((arr1 \ arr2) \ arr3) \ …).
Syntax
set_difference(set1, set2 [,set3, …])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| set1…setN | dynamic | ✔️ | Arrays used to create a difference set. A minimum of 2 arrays are required. See pack_array. |
Returns
Returns a dynamic array of the set of all distinct values that are in set1 but aren’t in other arrays.
Example
range x from 1 to 3 step 1
| extend y = x * 2
| extend z = y * 2
| extend w = z * 2
| extend a1 = pack_array(x,y,x,z), a2 = pack_array(x, y), a3 = pack_array(x,y,w)
| project set_difference(a1, a2, a3)
Output
| Column1 |
|---|
| [4] |
| [8] |
| [12] |
print arr = set_difference(dynamic([1,2,3]), dynamic([1,2,3]))
Output
| arr |
|---|
| [] |
Related content
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.