SAMPLE DAX Function (Statistical)

Returns a sample subset from a given table expression.

Syntax

SAMPLE ( <Size>, <Table>, <OrderBy> [, [<Order>] [, <OrderBy> [, [<Order>] [, … ] ] ] ] )
Parameter Attributes Description
Size

Number of rows in the sample to be returned.

Table
Iterator

A table expression from which the sample is generated.

OrderBy
Row Context
Repeatable

A scalar expression evaluated for each row of the table.

Order Optional
Repeatable

The order to be applied. 0/FALSE/DESC – descending; 1/TRUE/ASC – ascending.

Return values

Table An entire table or a table with one or more columns.

A table consisting of a sample of Size rows of table or an empty table if Size is 0 (zero) or less.

Remarks

A table consisting of a sample of N rows of table or an empty table if n_value is 0 (zero) or less.

One OrderBy argument is required. The returned sample will be stable and deterministic, returning the first row, the last row, and evenly distributed rows between them.

If n_value is 0 (zero) or less then SAMPLE returns an empty table.

In order to avoid duplicate values in the sample, the table provided as the second argument should be grouped by the column used for sorting.

Last update: Dec 13, 2018   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

MSDN documentation: https://msdn.microsoft.com/en-us/query-bi/dax/sample-function-dax

DAX Conventions
Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Deprecated

This parameter is deprecated and its use is not recommended.

Contribute

Want to improve the content of SAMPLE? Did you find any issue? Please, report it us!
All submissions will be evaluated for possible updates of the content.