Bearbeiten

Freigeben über


set_union()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Returns a dynamic array of the set of all distinct values that are in any of the arrays - (arr1 ∪ arr2 ∪ ...).

Syntax

set_union(set1, set2 [, set3, ...])

Learn more about syntax conventions.

Parameters

Name Type Required Description
set1...setN dynamic ✔️ Arrays used to create a union set. A minimum of two arrays are required. See pack_array.

Returns

Returns a dynamic array of the set of all distinct values that are in any of arrays.

Example

Set from multiple dynamic array

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(w)
| project a1,a2,a3,Out=set_union(a1, a2, a3)

Output

a1 a2 a3 Out
[1,2,1,4] [1,2] [8] [1,2,4,8]
[2,4,2,8] [2,4] [16] [2,4,8,16]
[3,6,3,12] [3,6] [24] [3,6,12,24]

Set from one dynamic array

datatable (Arr1: dynamic)
[
    dynamic(['A4', 'A2', 'A7', 'A2']), 
    dynamic(['C4', 'C7', 'C1', 'C4'])
] 
| extend Out=set_union(Arr1, Arr1)

Output

Arr1 Out
["A4","A2","A7","A2"] ["A4","A2","A7"]
["C4","C7","C1","C4"] ["C4","C7","C1"]