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

Get 10 distinct values from a population

StormEvents | sample-distinct 10 of EpisodeId

Sample a population and do further computation without exceeding the query limits in the summarize

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