Share via


How to sum in Application insight analytics query

Question

Monday, July 18, 2016 12:32 PM

Sample Query:

customEvents | where customDimensions.["ProcessID"]== "N20160717"
| summarize sum(customMeasures.["DocumentCount"]) by customDimensions.["ComponentName"]   we are trying to run the above query but we got the error. please correct the query.  Error : Ensure that expression: customMeasures["DocumentCount"] is indeed a simple name. Thanks in Advance.

All replies (3)

Monday, July 18, 2016 9:45 PM âś…Answered

Hi Arun,

Once using a custom property or custom measurement in an aggregation function, you should cast them to their exact type. Also there was a small typo where you should write customMeasurements and not customMeasures.

The following should work:

customEvents | where customDimensions.["ProcessID"]== "N20160717"
| summarize sum(todouble(customMeasurements.["DocumentCount"])) by tostring(customDimensions.["ComponentName"]) 

Thanks,

Yair


Tuesday, July 19, 2016 4:53 AM

Thanks Yair, Its working .

But the other doubt , is it possible to have one more aggregation filed say example in addition to the sum(DocumentCount) we also need sum(ProcessCount) and sum(failedCount) grouped by the "ComponentName".

Thanks in Advance.


Tuesday, July 19, 2016 5:07 AM

Hi,

Actually tried some other combinations, able to get the other aggregations too in the same, please find the sample query,

customEvents | where customDimensions .["ProcessID"] == "N20160717" | summarize sum(todouble(customMeasurements.["DocumentCount"])), sum(todouble(customMeasurements.["ProcessedCount"])), sum(todouble(customMeasurements.["FailedCount"])) by tostring(customDimensions.["ComponentName"])

 

we just used comma "," in the summarize to get the aggregations for the other fields too.

Thanks,
Arun