简体   繁体   English

Azure 分析 kusto 查询:如何按 2 个条件分组?

[英]Azure analytics kusto queries : how to group by 2 conditions?

I am using Azure analytics for a mobile app.我正在为移动应用程序使用 Azure 分析。 I have custom events for main app pages - that I can find inside the customEvents table.我有主应用程序页面的自定义事件 - 我可以在customEvents表中找到。

I am very new to kusto, so using the samples I found the following query:我对 kusto 很陌生,因此使用示例我发现了以下查询:

let start = startofday(ago(28d));
let events = union customEvents, pageViews
| where timestamp >= start
| where name in ('*') or '*' in ('*') or ('%' in ('*') and itemType == 'pageView') or ('#' in ('*') 
and itemType == 'customEvent')
| extend Dim1 = tostring(name);
let overall = events |  summarize Users = dcount(user_Id);
let allUsers = toscalar(overall);
events
| summarize Users = dcount(user_Id), Sessions = dcount(session_Id), Instances = count() by Dim1
| extend DisplayDim = strcat(' ', Dim1)
| order by Users desc
| project Dim1, DisplayDim, Users, Sessions, Instances
| project ['Activities'] = DisplayDim, Values = Dim1, ['Active Users'] = Users, ['Unique Sessions'] = Sessions, ['Total Instances'] = Instances

the query is working well, but I want to have all the page events grouped by client_CountryOrRegion查询运行良好,但我希望将所有页面事件按client_CountryOrRegion分组

查询结果

Is there any way I can do this split by client_CountryOrRegion?有什么办法可以按client_CountryOrRegion进行拆分吗?

Not sure if this is what you are looking for but if you want to have the result split by client_CountryOrRegion , you can just summarize by that column as well as:不确定这是否是您要查找的内容,但如果您想将结果按client_CountryOrRegion拆分,您可以按该列以及以下内容进行汇总:

let start = startofday(ago(28d));
let events = union customEvents, pageViews
| where timestamp >= start
| where name in ('*') or '*' in ('*') or ('%' in ('*') and itemType == 'pageView') or ('#' in ('*') 
and itemType == 'customEvent')
| extend Dim1 = tostring(name);
let overall = events |  summarize Users = dcount(user_Id);
let allUsers = toscalar(overall);
events
| summarize Users = dcount(user_Id), Sessions = dcount(session_Id), Instances = count() by Dim1, client_CountryOrRegion
| extend DisplayDim = strcat(' ', Dim1)
| order by Users desc
| project Dim1, DisplayDim, Users, Sessions, Instances
| project ['Activities'] = DisplayDim, Values = Dim1, ['Active Users'] = Users, ['Unique Sessions'] = Sessions, ['Total Instances'] = Instances, client_CountryOrRegion

The change is here:变化在这里:

summarize Users = dcount(user_Id), Sessions = dcount(session_Id), Instances = count() by Dim1 , client_CountryOrRegion通过 Dim1 总结用户 = dcount(user_Id)、会话 = dcount(session_Id)、实例 = count() 、client_CountryOrRegion

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Azure Kusto 查询比较 Jmeter 结果 - Compare Jmeter Results using Azure Kusto Queries 使用 Kusto Query 在 Azure LAWS 中创建计算机组 - Creating computer group in Azure LAWS with Kusto Query 如何在应用程序见解中创建Azure Kusto查询以仅按客户端操作系统名称(已删除操作系统版本)进行分组? - How to create an Azure Kusto query to group by client OS name only (OS version removed) on App insights? Azure Kusto 数据资源管理器 - 一次调用多个管理查询 - Azure Kusto Data Explorer - invoking multiple management queries at once 如何使用 Azure 流分析查询创建复杂类型 - How to create complex types with Azure Stream Analytics queries 将 Splunk 的“事务”命令转录到 Azure Log Analytics / Azure Data Analytics / Kusto - Transcribing Splunk's “transaction” Command into Azure Log Analytics / Azure Data Analytics / Kusto 如何在 Kusto 中进行“GROUP BY WITH ROLLUP”? - How can i do a "GROUP BY WITH ROLLUP" in Kusto? 如何监视Azure中的连续异常? (库斯托) - How to monitor consecutive exceptions in Azure? (Kusto) 如何在 Azure 中用 Kusto 划分计数? - How to divide the count number in with Kusto in Azure? 如何使用 Azure Kusto 输出多个变量? - How to output multiple variables using Azure Kusto?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM