Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi there. I'll give you an idea about how to do this. This is probably the only way to do it with the current version of DAX and Power BI.
First, let's say you have a table (call it 'Data') in the model with N rows which are numbered consecutively, say, from 0 to (N-1) (the column is called Index). Now, you'll construct a table ('Samples') with these properties:
Here's the structure:
k | Index | SampleId |
1 | 2 | 1 |
1 | 4 |
2 |
1 | 9 | 3 |
2 | 1 | 1 |
2 | 6 | 1 |
2 | 8 | 2 |
2 | 3 | 2 |
3 | 4 | 1 |
3 | 2 | 1 |
3 | 8 | 1 |
...
Can you see what's going on here? The k column will be sitting on one slicer, the SampleId on another. When you select a value of k, the other slicer will adjust the SampleId from 1 to the number of samples for that particular k. Now you just have to select a sample from the range slicer. This is how you'll obtain a (pseudo-)random selection of rows.
For each k you have to create samples where each sample will be a unique combination of the indexes of the rows to select. For k = 1, you only need N samples to cover all possibilities. For k = 2, you need N*(N-1)/2 combinations, for k = 3, you need C(N, k) combinations... but this number of samples will be going up quickly as k increases. So, when k is relatively big you don't need to cover all combinations. Just pick enough of them. Once you have the above table, you can write a measure [Select Row] that will return 1 if the row should be selected and 0 if not. Here it is:
[Select Row] =
var __k = SELECTEDVALUE( 'Samples'[K] )
var __oneSampleSelected = HASONEVALUE( 'Samples'[SampleId] )
var __currentRowid = SELECTEDVALUE( 'Data'[Index] )
var __selectRow =
__currentRowid in VALUES( 'Samples'[Index] )
return
if( __oneSampleSelected, 1 * __selectRow )
The visual in which you've placed the rows of the Data table should have a filter on it so that a row will display when [Select Row] is 1.
Best
D
Thank you vey miuch ! Will try this and update how it goes
check it out here
https://community.powerbi.com/t5/Desktop/DAX-random-sample/td-p/386571
Random Selection =
VAR SampleSize = 10
VAR TableWithRand = ADDCOLUMNS ( OriginalTable, "Rand", RAND () )
RETURN TOPN ( SampleSize, TableWithRand, [Rand] )
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.
how to take row count from users?
Create one table generateseries(1,1000)
then add it in slicer
Allow user to select number of samples
and undate it in above formula .
in var section add selectedvalue(table[series]) instead of 10.
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.
thanks for the reply , but not working unfortunately.
sorry my bad.
You can take user input here.
Because columns/tables are can not be dynamic.
They will get loaded at first load only.
So the formula will work for static values only not for dynamic values.
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
7 | |
5 | |
4 | |
3 |
User | Count |
---|---|
12 | |
11 | |
10 | |
9 | |
8 |