Märkus
Juurdepääs sellele lehele nõuab autoriseerimist. Võite proovida sisse logida või kausta vahetada.
Juurdepääs sellele lehele nõuab autoriseerimist. Võite proovida kausta vahetada.
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Creates a dynamic property-bag from two input dynamic arrays. In the resulting property-bag, the values from the first input array are used as the property keys, while the values from the second input array are used as corresponding property values.
Syntax
bag_zip(
KeysArray,
ValuesArray)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
KeysArray | dynamic |
✔️ | An array of strings. These strings represent the property names for the resulting property-bag. |
ValuesArray | dynamic |
✔️ | An array whose values will be the property values for the resulting property-bag. |
Note
- If there are more keys than values, missing values are filled with null.
- If there are more values than keys, values with no matching keys are ignored.
- Keys that aren't strings are ignored.
Returns
Returns a dynamic property-bag.
Examples
The following example shows how to use bag_zip()
to create a property-bag from two arrays. The first array contains the keys, and the second array contains the values. The resulting property-bag contains the keys and values zipped together.
let Data = datatable(KeysArray: dynamic, ValuesArray: dynamic) [
dynamic(['a', 'b', 'c']), dynamic([1, '2', 3.4])
];
Data
| extend NewBag = bag_zip(KeysArray, ValuesArray)
KeysArray | ValuesArray | NewBag |
---|---|---|
['a','b','c'] | [1,'2',3.4] | {'a': 1,'b': '2','c': 3.4} |
The following example shows how to use bag_zip()
when the arrays have different lengths. In this case, the resulting property-bag contains null values for the missing keys.
let Data = datatable(KeysArray: dynamic, ValuesArray: dynamic) [
dynamic(['a', 'b', 'c']), dynamic([1, '2'])
];
Data
| extend NewBag = bag_zip(KeysArray, ValuesArray)
KeysArray | ValuesArray | NewBag |
---|---|---|
['a','b','c'] | [1,'2'] | {'a': 1,'b': '2','c': null} |
The following example shows how to use bag_zip()
when the arrays have different lengths. In this case, the resulting property-bag contains null values for the missing keys.
let Data = datatable(KeysArray: dynamic, ValuesArray: dynamic) [
dynamic(['a', 'b']), dynamic([1, '2', 2.5])
];
Data
| extend NewBag = bag_zip(KeysArray, ValuesArray)
KeysArray | ValuesArray | NewBag |
---|---|---|
['a','b'] | [1,'2',2.5] | {'a': 1,'b': '2'} |
The following example demonstrates how bag_zip()
handles cases where the keys array contains non-string values. Any key that isn't a string is excluded from the resulting property-bag.
let Data = datatable(KeysArray: dynamic, ValuesArray: dynamic) [
dynamic(['a', 8, 'b']), dynamic([1, '2', 2.5])
];
Data
| extend NewBag = bag_zip(KeysArray, ValuesArray)
KeysArray | ValuesArray | NewBag |
---|---|---|
['a',8,'b'] | [1,'2',2.5] | {'a': 1,'b': 2.5} |
The following example demonstrates how bag_zip()
behaves when the parameter intended to be an array of values is not actually an array. In this case, all resulting property values are set to null.
let Data = datatable(KeysArray: dynamic, ValuesArray: dynamic) [
dynamic(['a', 8, 'b']), dynamic(1)
];
Data
| extend NewBag = bag_zip(KeysArray, ValuesArray)
KeysArray | ValuesArray | NewBag |
---|---|---|
['a',8,'b'] | 1 | {'a': null,'b': null} |
The following example demonstrates how bag_zip()
behaves when the parameter intended to be an array of keys is not actually an array. In this case, the resulting property-bag is null.
let Data = datatable(KeysArray: dynamic, ValuesArray: dynamic) [
dynamic('a'), dynamic([1, '2', 2.5])
];
Data
| extend NewBag = bag_zip(KeysArray, ValuesArray)
| extend IsNewBagEmpty=isnull(NewBag)
KeysArray | ValuesArray | NewBag | IsNewBagEmpty |
---|---|---|---|
a | [1,'2',2.5] | TRUE |