DAX Function Guide

SAMPLE
Empty image or helper icon

Sam McKay

CEO & Founder

How does the SAMPLE work?
The SAMPLE function (DAX) returns a sample of N rows from the specified table.
SAMPLE Formula Syntax

SAMPLE (
     <n_value>, <table>, <orderBy_expression>, [<order>], [<orderBy_expression>, [<order>]] …
)

How do you use the SAMPLE?

This function can be used to return table consisting of a sample of N rows of table or an empty table if n_value is 0 (zero) or less.

Related Blog Posts

Loading

Considerations when using the SAMPLE?

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.

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.

Related Video Tutorials

Loading

Formula examples using the SAMPLE

= SUMX (SAMPLE (DISTINCTCOUNT (Sales[Month]), Sales,Sales[Salesperson],ASC), [Sales Amount])

SAMPLE( 3,’Data’, RAND() )

Related Courses

Loading