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

Viewed 7952

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"]

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.

Related