Skip to content

Instantly share code, notes, and snippets.

@bennybauer
Last active November 19, 2017 08:53
Show Gist options
  • Save bennybauer/77559b1f80804b9fbb4d6684ec31130a to your computer and use it in GitHub Desktop.
Save bennybauer/77559b1f80804b9fbb4d6684ec31130a to your computer and use it in GitHub Desktop.
Azure Application Insights query to fetch weekly totals of all custom events
customEvents
| where timestamp between (startofweek(ago(14d))..now())
| make-series dcount(user_Id) on timestamp in range(startofweek(now()),endofweek(now()), 7d) by name
| mvexpand timestamp, dcount_user_Id
| extend Week = weekofyear(todatetime(timestamp))
| project Week, timestamp, name, toint(dcount_user_Id)
| summarize sum(dcount_user_Id) by name, Week, tostring(timestamp)
| order by Week desc, sum_dcount_user_Id desc
| evaluate pivot(name, sum(sum_dcount_user_Id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment