Home > Mobile >  kql - get all values from a dictionary
kql - get all values from a dictionary

Time:02-16

Is it possible to get an array of values from a dictionary?

let T = datatable(prop:string, value:string)
[
    "prop01", "val_a",
    "prop02", "val_b",
    "prop03", "val_c",
];
T
| extend p = pack(prop, value)
| summarize dict=make_bag(p)

I need ["val_a","val_b","val_"]

Smth like Python myDict.values()

CodePudding user response:

you can use mv-apply make_list() to achieve that.

you can also submit a feature request for a bag_values() function @ https://aka.ms/adx.ideas.

datatable(dict:dynamic)
[
    dynamic({
        "prop01": "val_a",
        "prop02": "val_b",
        "prop03": "val_c"
    }), 
]
| mv-apply dict on (
    extend key = tostring(bag_keys(dict)[0])
    | summarize values = make_list(dict[key])
)
| project values
values
[
"val_a",
"val_b",
"val_c"
]
  • Related