Kusto:如何查询每日数据以按月聚合并生成趋势
Kusto :How to query daily data to aggregate by Month and generate trends
我们的 kusto table 有过去 12 个月的每日数据,我正在尝试获取过去 6 个月的趋势 1) 每个月的不同 customerId 数量
2) 每个客户 (customerId) 的订单数(使用 orderId 字段)按月
我在下面尝试了 #1 个问题,但它没有给出正确的结果,看起来像对 bin 函数的理解不准确。请问我应该使用什么功能来获取#1 和#2 问题数据?
注意:每天都有9am、12pm、18pm、12pm等多批数据
let data = datatable(customerid:int, processdate:datetime, orderId: string)
[
1,"2021-03-03 09:00:00", "a",
1,"2021-03-03 12:00:00", "b",
1,"2021-03-03 15:00:00", "c",
2,"2021-03-04 21:00:00", "d",
2,"2021-03-04 14:00:00", "e",
2,"2021-03-04 09:00:00", "f",
1,"2021-04-03 09:00:00", "g",
1,"2021-04-03 12:00:00", "h",
1,"2021-04-03 15:00:00", "j",
2,"2021-05-04 21:00:00", "k",
2,"2021-05-04 14:00:00", "l",
2,"2021-05-04 09:00:00", "m"
];
data
//|where processdate > ago(180d) commeted out as example data does not data to satisfy this filter
|summarize customercount = dcount(customerid) by bin(processdate,30d)
我们的 kusto table 有过去 12 个月的每日数据,我正在尝试获取过去 6 个月的趋势 1) 每个月的不同 customerId 数量 2) 每个客户 (customerId) 的订单数(使用 orderId 字段)按月
我在下面尝试了 #1 个问题,但它没有给出正确的结果,看起来像对 bin 函数的理解不准确。请问我应该使用什么功能来获取#1 和#2 问题数据?
注意:每天都有9am、12pm、18pm、12pm等多批数据
let data = datatable(customerid:int, processdate:datetime, orderId: string)
[
1,"2021-03-03 09:00:00", "a",
1,"2021-03-03 12:00:00", "b",
1,"2021-03-03 15:00:00", "c",
2,"2021-03-04 21:00:00", "d",
2,"2021-03-04 14:00:00", "e",
2,"2021-03-04 09:00:00", "f",
1,"2021-04-03 09:00:00", "g",
1,"2021-04-03 12:00:00", "h",
1,"2021-04-03 15:00:00", "j",
2,"2021-05-04 21:00:00", "k",
2,"2021-05-04 14:00:00", "l",
2,"2021-05-04 09:00:00", "m"
];
data
//|where processdate > ago(180d) commeted out as example data does not data to satisfy this filter
|summarize customercount = dcount(customerid) by bin(processdate,30d)