DotNetNewbie1024
DotNetNewbie1024

Reputation: 65

How to do a distinct on Azure Application Insights Analytics

I currently have the following query that I run with Application Insights Analytics:

customEvents 
| where name == 'Event Name 1' 
| project ['Column One'] = customDimensions['CD1'], ['Column Two'] = customDimensions['CD2'], ['Column Three'] = customDimensions['CD3']

The above query returns me some results like the following:

Column One | Column Two | Column Three
    A      |     2      |      D
    B      |     3      |      E
    C      |     2      |      F

How do I get the Query to return me only distinct values on column two? Basically I want my result to be:

Column One | Column Two | Column Three
    A      |     2      |      D
    B      |     3      |      E

Any help would be greatly appreciated!

Upvotes: 2

Views: 1923

Answers (1)

ZakiMa
ZakiMa

Reputation: 6241

You can do something like this:

customEvents 
| where name == 'Event Name 1' 
| project ['Column One'] = tostring(customDimensions['CD1']),
          ['Column Two'] = tostring(customDimensions['CD2']),
          ['Column Three'] = tostring(customDimensions['CD3'])
| summarize any(['Column One']), any(['Column Three']) by ['Column Two']

This will pick up the first - not necessarily A in "A, C" pair. If you want to exclude "C" then you need to use other summarize aggregators like makelist/makeset.

Upvotes: 2

Related Questions