Forum Discussion
DAX random sample
- 8 years ago
Hi Christann
To create a random sample table with DAX, I would use RAND() as suggested above, and create a table with an expression like this:
Random Selection = VAR SampleSize = 10 VAR TableWithRand = ADDCOLUMNS ( OriginalTable, "Rand", RAND () ) RETURN TOPN ( SampleSize, TableWithRand, [Rand] )The Random Selection table will end up with an extra column Rand but you can remove that if needed.
It appears that the SAMPLE function returns a deterministic sample.
Regards,
Owen
Hi Christann
To create a random sample table with DAX, I would use RAND() as suggested above, and create a table with an expression like this:
Random Selection =
VAR SampleSize = 10
VAR TableWithRand =
ADDCOLUMNS ( OriginalTable, "Rand", RAND () )
RETURN
TOPN ( SampleSize, TableWithRand, [Rand] )The Random Selection table will end up with an extra column Rand but you can remove that if needed.
It appears that the SAMPLE function returns a deterministic sample.
Regards,
Owen
I would like to generate a random sample in this same way, but adding a location, date and time criteria to te sample return? For example, 1 row for every hour on each day at each location. Is this possible?