Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
431 views
in Technique[技术] by (71.8m points)

Application Insights Kusto (KQL): How to sort items produced by make_set operator

I'm trying to group different kinds by a version. Here is the simplest repro/example:

let Source = datatable(Name:string, Version:string)
[
    'Car', '1.0.0',
    'Train', '2.0.0',
    'Train', '1.0.0',
    'Car', '2.0.0'
];
Source
| summarize make_set(Name) by Version

Right now the the kinds appear according to the order of individual records:

enter image description here

As a result it is hard to compare lines. Wonder how to make items sorted in make_set.

question from:https://stackoverflow.com/questions/66068955/application-insights-kusto-kql-how-to-sort-items-produced-by-make-set-operato

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could use array_sort_asc() / array_sort_desc():

For example:

let Source = datatable(Name:string, Version:string)
[
    'Car', '1.0.0',
    'Train', '2.0.0',
    'Train', '1.0.0',
    'Car', '2.0.0'
];
Source
| summarize Names = array_sort_asc(make_set(Name)) by Version

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...