SAMPLE

Updated on

SAMPLE is a DAX function that returns a subset of rows from a given table expression.

Syntax

SAMPLE(
   Size,
   Table,
   [ OrderBy, ... ],
   [ Order, ... ]
)
Argument Properties Description
Size Number of rows in the sample to be returned.
Table A table expression from which the sample is generated.
OrderBy 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

A table consisting of a sample of N rows of table or an empty table if n_value is 0 (zero) or less. If OrderBy arguments are provided, the sample will be stable and deterministic, returning the first row, the last row, and evenly distributed rows between them. If no ordering is specified, the sample will be random, not stable, and not deterministic.

Remarks

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

  • This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

Empty

Other functions related to SAMPLE are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/sample-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy