user989988
user989988

Reputation: 3746

Perform some calculation using kusto query

I have the following kusto query:


customEvents
| where name == "Tracker"
| project Id = tostring(customDimensions["Id"]),
          Rank = tostring(customDimensions["Rank"])

which gives the following result:

enter image description here

I need to calculate the total number of rows / total number of rows with Rank >= 1 (in this case, total number of rows = 2, total number of rows with Rank >= 1 is 1 so 2/1 = 2) in kusto query. How do I add this in the above kusto query?

Upvotes: 1

Views: 254

Answers (1)

Yoni L.
Yoni L.

Reputation: 25995

you can use the countif() aggregation function.

for example:

customEvents
| where name == "Tracker"
| project Rank = tolong(customDimensions["Rank"])
| summarize result = count() / countif(Rank >= 1)

Upvotes: 1

Related Questions