[英]Aggregate over multiple columns in Azure (Kusto Query Language)
I have clickstream data in Azure monitor logs in this format:我在 Azure 监控日志中有点击流数据,格式如下:
Category StepName Count_ Median_Duration(secs)
A step1 1200 00:00
A step2 1000 24:00
A step3 800 19:00
B step1 4000 00:00
B step2 3800 37:00
I need to pivot the table to get this:我需要 pivot 表来得到这个:
Category Step1_Count Step1_Duration Step2_Count Step2_Duration Step3_Count ...
A 1200 00:00 1000 24:00 800 ...
B 4000 00:00 3800 37:00 0 ...
Right now I am only able to aggregate over one column using evaluate pivot(StepName, sum(Count_)) or evaluate pivot(StepName, sum(Median_Duration)).现在我只能使用评估数据透视(StepName,sum(Count_))或评估数据透视(StepName,sum(Median_Duration))聚合一列。 Is it possible to get the above format without using joins?
是否可以在不使用连接的情况下获得上述格式?
Note: Similar formats to the output table are fine, just need the aggregate of the count and duration.注意:类似于 output 表的格式可以,只需要计数和持续时间的聚合。
you could try something along the following lines:您可以尝试以下方式:
datatable(Category:string, StepName:string, Count_:long, Median_Duration:timespan)
[
"A", "step1", 1200, time(00:00:00),
"A", "step2", 1000, time(00:00:24),
"A", "step3", 800, time(00:00:19),
"B", "step1", 4000, time(00:00:00),
"B", "step2", 3800, time(00:00:37),
]
| summarize StepCount = sum(Count_), Duration = avg(Median_Duration) by Category, StepName
| project Category, p = pack(strcat(StepName, "_Count"), StepCount, strcat(StepName, "_Duration"), Duration)
| summarize b = make_bag(p) by Category
| evaluate bag_unpack(b)
or, if you're ok with a different output schema:或者,如果您可以使用不同的 output 架构:
datatable(Category:string, StepName:string, Count_:long, Median_Duration:timespan)
[
"A", "step1", 1200, time(00:00:00),
"A", "step2", 1000, time(00:00:24),
"A", "step3", 800, time(00:00:19),
"B", "step1", 4000, time(00:00:00),
"B", "step2", 3800, time(00:00:37),
]
| summarize StepCount = sum(Count_), Duration = avg(Median_Duration) by Category, StepName
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.