SAMPLE Function (DAX)
How does the SAMPLE function (DAX) 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 function?
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
Related Support Forum Posts
Google analytics report sample
Extract Zip Code from String with Inconsistent Format
Grouping based on single record item
Considerations when using the SAMPLE function
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
Formula examples using the SAMPLE function
= SUMX (SAMPLE (DISTINCTCOUNT (Sales[Month]), Sales,Sales[Salesperson],ASC), [Sales Amount])
SAMPLE( 3,’Data’, RAND() )