Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a distinct on Azure Application Insights Analytics and then project few variables from the new distinct set

I have a query to find out the distinct user Ids and their country, agency name, city code who use a specific product version. How do I list the properties successfully? Below query doesn't have filter out the unique users.

customEvents | where customDimensions.["Product Version"] == "7.4" | where timestamp between(datetime("2018-12-01T00:00:00.000Z")..datetime("2018-12-02T00:00:00.000Z")) | project client_CountryOrRegion, user_Id, customDimensions.["Agency Name"], customDimensions.["Pseudo City Code"], customDimensions.["Product Version"]

like image 426
user3669982 Avatar asked Jan 09 '19 01:01

user3669982


People also ask

How do I get unique values in KQL?

Re: kql query for distinct values If that is not an issue then after you get your host and your displayName, you can concatenate (using the strcat command) and then perform another distinct on the concatenated string. Hope this is what you are looking for.


1 Answers

update:

Please use alias when use tostring() method. And then in the project command, use the alias instead of the column name.

See my test result as below:

enter image description here


Before the project syntax, please use summarize count() by client_CountryOrRegion, user_Id, customDimensions.["Agency Name"], customDimensions.["Pseudo City Code"], customDimensions.["Product Version"] , then use project to output the properties your like.

Completed code like below:

customEvents
| where customDimensions.["Product Version"] == "7.4" 
| where timestamp between(datetime("2018-12-01T00:00:00.000Z")..datetime("2018-12-02T00:00:00.000Z")) 
| summarize count() by client_CountryOrRegion, user_Id, customDimensions.["Agency Name"], customDimensions.["Pseudo City Code"], customDimensions.["Product Version"]
| project client_CountryOrRegion, user_Id, customDimensions.["Agency Name"], customDimensions.["Pseudo City Code"], customDimensions.["Product Version"]

Please let me if any issues.

like image 183
Ivan Yang Avatar answered Sep 28 '22 06:09

Ivan Yang