Forum Discussion
How to aggregate results from a query
- Sep 17, 2020
instead of mv-expanding DeviceDetail (you're creating new rows) you should extend it to new columns, by using the extend operator, such as
| extend OS = DeviceDetail.operatingSystem, Browser = DeviceDetail.browser
Hi MichalZiemba,
In order to summarize you first need to figure out what are the expected results, and how you want to summarize your results, I couldn't figure out from your description what is the desired result set.
For summarize you should use an aggregation function (if you don't use one the functionality is the same as the 'distinct' operator).
I'd suggest here the simplest function which is 'count()', it will give you the count of unique combinations occurrences of the columns mentioned on the right hand of the expression (after 'by'), try adding the following line to the end of your query:
| summarize count() by Mail, User_Name, Application_name, Protocol, tostring(Device.displayName), tostring(Device.operatingSystem)
Here is a link to 'summarize' documentation: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/summarizeoperator
Thanks,
Rafi
Hi Rafi_Rabo
Sorry if I were not clear about my goal and thank you for your tip.
If I run a simple query:
SigninLogs
|where CorrelationId == "###-#-#-10c620ed816d"
- hspintoSep 17, 2020
Microsoft
instead of mv-expanding DeviceDetail (you're creating new rows) you should extend it to new columns, by using the extend operator, such as
| extend OS = DeviceDetail.operatingSystem, Browser = DeviceDetail.browser- MichalZiembaSep 17, 2020MCT
Thank you very much.
I have combined it to this (maybe not so elegant) query and it does what I wanted.
SigninLogs | where TimeGenerated > ago(14d) | mvexpand PolicyResults = ConditionalAccessPolicies | where PolicyResults.id == "e60d3233-####-004016656ca4" and PolicyResults.result != "reportOnlyNotApplied" | extend OS = DeviceDetail.operatingSystem, Browser = DeviceDetail.browser, displayName=tostring(DeviceDetail.displayName),deviceId= tostring(DeviceDetail.deviceId), trustType= tostring(DeviceDetail.trustType) |summarize count() by Mail=UserPrincipalName, User_Name=UserDisplayName, Application_name=AppDisplayName, Protocol=ClientAppUsed, displayName, deviceId, trustType , tostring(OS), tostring(Browser)- CliveWatsonSep 25, 2020Former Employee
FYI, https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/mvexpandoperator
mv-expand has replaced mvexpand
Note
The legacy and obsolete form of the operator
mvexpandhas a default row limit of 128.