SAMPLE DAX Function (Statistical)

Returns a sample subset from a given table expression.


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

Number of rows in the sample to be returned.


A table expression from which the sample is generated.

Row Context

A scalar expression evaluated for each row of the table.

Order Optional

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.


A table consisting of a sample of N rows of table or an empty table if Size 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 Size 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: Jan 23, 2021   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber

MSDN documentation:

2018-2021 © SQLBI. All rights are reserved. Information coming from MSDN is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

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.


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.


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


This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.


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.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.