英文:
Kusto query Past 3 days data with setting 0 for no data for that date
问题
第一次尝试使用KQL,希望有人能帮助我。
我需要过去三天内,每天每个用户的事件计数,与创建日期相关。
结果应该类似于:
创建日期 | 用户 | 计数 |
---|---|---|
2023年05月31日 | Ali | 1 |
2023年05月30日 | Ali | 0 |
2023年05月29日 | Ali | 2 |
2023年05月31日 | Ken | 1 |
2023年05月30日 | Ken | 2 |
2023年05月29日 | Ken | 0 |
如果某天没有数据,请将计数设置为0。我尝试了以下代码:
events
| where created >= ago(3d)
| summarize Count = count() by created = bin(created, 1d), user
| project created = format_datetime(created, 'dd/MM/yyyy'), user, Count
| order by created desc
但是如何为没有数据的那一天填充0呢?
英文:
First time trying kql, hope someone could help me.
I need past 3 days of each day event count with respect to created date and by each of the user.
Result would be something like:
Created | User | Count |
---|---|---|
31/05/2023 | Ali | 1 |
30/05/2023 | Ali | 0 |
29/05/2023 | Ali | 2 |
31/05/2023 | Ken | 1 |
30/05/2023 | Ken | 2 |
29/05/2023 | Ken | 0 |
If there is no data on that day, put 0 as the count. I tried something like:
events
| where created >= ago(3d)
| summarize Count = count() by created = bin(created, 1d), user
| project created = format_datetime(created, 'dd/MM/yyyy'), user, Count
| order by created desc
But how can i fill the 0 for the count for the day that has no data?
答案1
得分: 2
你可以考虑使用 make-series
运算符,而不是使用 summarize
运算符。
英文:
You can consider using the make-series
operator instead of the summarize
operator
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论