2

我正在将 Azure 分析用于移动应用程序。我有主应用程序页面的自定义事件 - 我可以在customEvents表中找到。

我对 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

查询运行良好,但我希望将所有页面事件按client_CountryOrRegion分组

查询结果

有什么办法可以按client_CountryOrRegion进行拆分吗?

4

1 回答 1

2

不确定这是否是您要查找的内容,但如果您想将结果拆分为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

变化在这里:

通过 Dim1 总结用户 = dcount(user_Id)、会话 = dcount(session_Id)、实例 = count() 、client_CountryOrRegion

于 2019-11-19T12:00:00.290 回答