azurekqlazure-monitoringazure-sdk-for-java

Dividing the results of multiple queries in Azure KQL


I have a series of KQL queries (Query1, Query2, Query3, Query4) and I'm looking to perform a calculation on their results. Specifically, I want to divide the result of (Query1 + Query2) by (Query3 + Query4).

Here's the pseudo-code of what I'm trying to achieve:

Result = (Query1 + Query2) / (Query3 + Query4)

Is there a way to accomplish this directly within Azure KQL?

I've tried experimenting with different approaches, but I'm not sure if I'm on the right track. Any guidance or examples would be greatly appreciated. Thank you!


Solution

  • you should be able to achieve that using toscalar():

    let result1 = toscalar(...query1...);
    let result2 = toscalar(...query2...);
    let result3 = toscalar(...query3...);
    let result4 = toscalar(...query4...);
    print result = (result1 + result2) / (result3 + result4)