Skip to content

Commit 05a4909

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/dataexplorer-docs-pr (branch live)
2 parents 0b3498d + d84256b commit 05a4909

1 file changed

Lines changed: 38 additions & 13 deletions

File tree

data-explorer/kusto/query/top-hitters-operator.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: top-hitters operator
33
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
55
ms.topic: reference
6-
ms.date: 04/06/2025
6+
ms.date: 05/18/2026
77
---
88
# top-hitters operator
99

@@ -13,9 +13,10 @@ Returns an approximation for the most popular distinct values, or the values
1313
with the largest sum, in the input.
1414

1515
> [!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.
1920
2021
## Syntax
2122

@@ -27,17 +28,17 @@ with the largest sum, in the input.
2728

2829
| Name | Type | Required | Description |
2930
|--|--|--|--|
30-
| *T* | `string` | :heavy_check_mark: | The input tabular expression.|
31+
| *T* | `tabular expression` | :heavy_check_mark: | The input tabular expression.|
3132
| *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.|
3435

3536
> [!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:
3738
>
3839
> `T | summarize S = sum(SummingExpression) by ValueExpression | top NumberOfValues by S desc`
3940
>
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:
4142
>
4243
> `T | summarize C = count() by ValueExpression | top NumberOfValues by C desc`
4344
@@ -48,7 +49,7 @@ The examples in this section show how to use the syntax to help you get started.
4849
[!INCLUDE [help-cluster-note](../includes/help-cluster-note.md)]
4950

5051

51-
### Get top 2 events by totals ###
52+
### Get top two events by totals ###
5253

5354
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.
5455

@@ -72,7 +73,7 @@ StormEvents
7273

7374
### Get most frequent items
7475

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.
7677

7778
:::moniker range="azure-data-explorer"
7879
> [!div class="nextstepaction"]
@@ -96,7 +97,7 @@ StormEvents
9697

9798
### Get top hitters based on column value
9899

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.
100101

101102
:::moniker range="azure-data-explorer"
102103
> [!div class="nextstepaction"]
@@ -123,3 +124,27 @@ StormEvents
123124
| VIRGINIA | 482 |
124125
| KANSAS | 476 |
125126
| 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+
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAAwsuyS/KdS1LzSsp5qpRKMkv0M3ILClJLSpWCEnMTQSxQioLUhWC83MLSjKL8vOKFUIyc1OLSzLz8xQUNAFsNgvlPAAAAA==" target="_blank">Run the query</a>
135+
::: moniker-end
136+
137+
```kusto
138+
StormEvents
139+
| top-hitters 5 of EventType by DamageProperty
140+
```
141+
142+
**Output**
143+
144+
| EventType | approximate_sum_DamageProperty |
145+
|---|---|
146+
| Flood | 1,124,327,850 |
147+
| Flash Flood | 626,659,030 |
148+
| Tornado | 492,562,280 |
149+
| Hail | 479,070,850 |
150+
| Thunderstorm Wind | 221,037,650 |

0 commit comments

Comments
 (0)