2

I am using Azure analytics for a mobile app. I have custom events for main app pages - that I can find inside the customEvents table.

I am very new to kusto, so using the samples I found the following query:

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

query result

Is there any way I can do this split by client_CountryOrRegion?

Codrina Valo
  • 433
  • 1
  • 5
  • 14

1 Answers1

2

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:

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

Peter Bons
  • 26,826
  • 4
  • 50
  • 74
  • thanks, I added this and also figured out the project part project Dim1, DisplayDim, Users, Sessions, Instances, client_CountryOrRegion | project ['Activities'] = DisplayDim, Values = Dim1, ['Active Users'] = Users, ['Unique Sessions'] = Sessions, ['Total Instances'] = Instances, ['Country'] = client_CountryOrRegion – Codrina Valo Nov 19 '19 at 12:44