sample-distinct operator

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Returns a single column that contains up to the specified number of distinct values of the requested column.

The operator tries to return an answer as quickly as possible rather than trying to make a fair sample.

Syntax

T | sample-distinct NumberOfValues of ColumnName

Learn more about syntax conventions.

Parameters

Name Type Required Description
T string ✔️ The input tabular expression.
NumberOfValues int, long, or real ✔️ The number distinct values of T to return. You can specify any numeric expression.
ColumnName string ✔️ The name of the column from which to sample.

Tip

Examples

The example in this section shows how to use the syntax to help you get started.

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the StormEvents table in the Weather analytics sample data.

Get 10 distinct values from a population

StormEvents | sample-distinct 10 of EpisodeId

Output

EpisodeId
11074
11078
11749
12554
12561
13183
11780
11781
12826

Further compute the sample values

let sampleEpisodes = StormEvents | sample-distinct 10 of EpisodeId;
StormEvents 
| where EpisodeId in (sampleEpisodes) 
| summarize totalInjuries=sum(InjuriesDirect) by EpisodeId

Output

EpisodeId totalInjuries
11091 0
11074 0
11078 0
11749 0
12554 3
12561 0
13183 0
11780 0
11781 0
12826 0