Forum Discussion
killer85
1 year agoRegular Visitor
Generating Dynamic Random Sample in Power BI with Custom Constraints
Hello Power BI Community, I hope you’re all doing well! I’m currently working on a project where I need to generate a dynamic random sample from a dataset of approximately 4,000 to 5,000 rows, with...
- 1 year ago
Here is a sample setup, assuming even distribution.
Table:
Samples = ADDCOLUMNS(GENERATESERIES(1,5000),"Rand",RAND())Filter Measure:
Include = if(sum(Samples[Rand])<=[Sample size Value],1,0)If you need it more precise, use percentilex.:
Include = if(sum(Samples[Rand])<=PERCENTILEX.INC(all(Samples[Rand]),[Rand],[Sample size Value]),1,0)Row count measure:
Included Rows = COUNTROWS(FILTER(Samples,[Include]=1))
lbendlin
1 year agoSuper User
Here is a sample setup, assuming even distribution.
Table:
Samples = ADDCOLUMNS(GENERATESERIES(1,5000),"Rand",RAND())
Filter Measure:
Include = if(sum(Samples[Rand])<=[Sample size Value],1,0)
If you need it more precise, use percentilex.:
Include = if(sum(Samples[Rand])<=PERCENTILEX.INC(all(Samples[Rand]),[Rand],[Sample size Value]),1,0)
Row count measure:
Included Rows = COUNTROWS(FILTER(Samples,[Include]=1))
killer85
1 year agoRegular Visitor
Hi Ibendlin,
First I should start by wishing all the best for this new year 2025.
Thank you for your very clear explanations. I still don’t understand why I didn’t get it before, as it seems quite easy to set up.
Thanks for your support.