0

I am trying to get data on the type of browsers our customers are using. I want to have a pie chart that displays the percentage of Chrome users, the percentage of Firefox/Mozilla users, percentage of Safari users, and the percentage of Edge/IE users.

Using the following query I can list all the unique browser types: Chrome57, Chrome59, etc...

customEvents
| where timestamp >= ago(7d)
| summarize Count=count(customDimensions.Type) by Browser=tostring(customDimensions.Type)
| project Browser,Count

How can I aggregate the browsers that have the same name but different version? For instance, add all the Chrome browsers into one giant total.

user10140546
  • 370
  • 3
  • 16

1 Answers1

0

The easiest would be to log customDimension.Type without the browser version on data collection step. If that's not an option, the second easiest would be to use reduce operator to avoid regex string operations to extract only browser name.

If used after projecting customDimensions.Type, then it will automatically group matching string (browser names) and will provide counts for them as well as an example browser string matching the wildcard.

Syntax

T | reduce [kind = ReduceKind] by Expr [with [threshold = Threshold] [, characters = Characters] ]

Arguments

Expr: An expression that evaluates to a string value.
Threshold: A real literal in the range (0..1). Default is 0.1. For large inputs, threshold should be small.
Characters: A string literal containing a list of characters to add to the list of characters that don't break a term. (For example, if you want aaa=bbbb and aaa:bbb to each be a whole term, rather than break on = and :, use ":=" as the string literal.)
ReduceKind: Specifies the reduce flavor. The only valid value for the time being is source.

Returns

This operator returns a table with three columns (Pattern, Count, and Representative), and as many rows as there are groups. Pattern is the pattern value for the group, with * being used as a wildcard (representing arbitrary insertion strings), Count counts how many rows in the input to the operator are represented by this pattern, and Representative is one value from the input that falls into this group.

P.S

Alternatively, you can give a shot to regex extraction of the name (e.g. extract everything before any number and use it as a browser name).

Dmitry Matveev
  • 2,563
  • 11
  • 16