You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: data-explorer/kusto/query/top-hitters-operator.md
+38-13Lines changed: 38 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
---
2
2
title: top-hitters operator
3
3
description: Learn how to use the top-hitters operator to return an approximation for the most popular distinct values in the input.
4
-
ms.reviewer: alexans
4
+
ms.reviewer: zivc
5
5
ms.topic: reference
6
-
ms.date: 04/06/2025
6
+
ms.date: 05/18/2026
7
7
---
8
8
# top-hitters operator
9
9
@@ -13,9 +13,10 @@ Returns an approximation for the most popular distinct values, or the values
13
13
with the largest sum, in the input.
14
14
15
15
> [!NOTE]
16
-
> `top-hitters` uses an approximation algorithm optimized for performance
17
-
> when the input data is large.
18
-
> The approximation is based on the [Count-Min-Sketch](https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch) algorithm.
16
+
> The `top-hitters` operator uses an approximation algorithm that's optimized for performance when the input data is large.
17
+
> The approximation is based on the [Count-Min-Sketch](https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch) algorithm.
18
+
>
19
+
> This operator is non-deterministic. Running it twice over the same data doesn't guarantee the same results.
19
20
20
21
## Syntax
21
22
@@ -27,17 +28,17 @@ with the largest sum, in the input.
27
28
28
29
| Name | Type | Required | Description |
29
30
|--|--|--|--|
30
-
|*T*|`string`|:heavy_check_mark:| The input tabular expression.|
31
+
|*T*|`tabular expression`|:heavy_check_mark:| The input tabular expression.|
31
32
|*NumberOfValues*| int, long, or real |:heavy_check_mark:| The number of distinct values of *ValueExpression*.|
32
-
|*ValueExpression*|`string`|:heavy_check_mark:| An expression over the input table *T* whose distinct values are returned.|
33
-
|*SummingExpression*|`string`|| If specified, a numeric expression over the input table *T* whose sum per distinct value of *ValueExpression* establishes which values to emit. If not specified, the count of each distinct value of *ValueExpression* is used instead.|
33
+
|*ValueExpression*|`scalar`|:heavy_check_mark:| An expression over the input table *T* whose distinct values are returned.|
34
+
|*SummingExpression*|`long` or `real`|| If specified, a numeric expression over the input table *T* whose sum per distinct value of *ValueExpression* establishes which values to emit. If not specified, the count of each distinct value of *ValueExpression* is used instead.|
34
35
35
36
> [!NOTE]
36
-
> * When you include *SummingExpression* in the syntax, the query is equivalent to:
37
+
> * When you include *SummingExpression* in the syntax, the query approximates the value of:
37
38
>
38
39
> `T | summarize S = sum(SummingExpression) by ValueExpression | top NumberOfValues by S desc`
39
40
>
40
-
> * When you don't include *SummingExpression* in the syntax, the query is equivalent to:
41
+
> * When you don't include *SummingExpression* in the syntax, the query approximates the value of:
41
42
>
42
43
> `T | summarize C = count() by ValueExpression | top NumberOfValues by C desc`
43
44
@@ -48,7 +49,7 @@ The examples in this section show how to use the syntax to help you get started.
This example summarizes storm event data by calculating the total number of events for each event type. The query then selects the top two event types with the highest total number of events.
54
55
@@ -72,7 +73,7 @@ StormEvents
72
73
73
74
### Get most frequent items
74
75
75
-
This example shows how to find the top-5 types of storms.
76
+
This example shows how to find the top five types of storms.
76
77
77
78
:::moniker range="azure-data-explorer"
78
79
> [!div class="nextstepaction"]
@@ -96,7 +97,7 @@ StormEvents
96
97
97
98
### Get top hitters based on column value
98
99
99
-
This example shows how to find the States with the most *Thunderstorm Wind* events.
100
+
This example shows how to find the states with the most *Thunderstorm Wind* events.
100
101
101
102
:::moniker range="azure-data-explorer"
102
103
> [!div class="nextstepaction"]
@@ -123,3 +124,27 @@ StormEvents
123
124
| VIRGINIA | 482 |
124
125
| KANSAS | 476 |
125
126
| OHIO | 455 |
127
+
128
+
### Get top hitters by summed value
129
+
130
+
This example finds the event types with the highest total property damage, using `DamageProperty` as the summing expression.
131
+
132
+
:::moniker range="azure-data-explorer"
133
+
> [!div class="nextstepaction"]
134
+
> <ahref="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAAwsuyS/KdS1LzSsp5qpRKMkv0M3ILClJLSpWCEnMTQSxQioLUhWC83MLSjKL8vOKFUIyc1OLSzLz8xQUNAFsNgvlPAAAAA=="target="_blank">Run the query</a>
0 commit comments