Forum Discussion
Generating Dynamic Random Sample in Power BI with Custom Constraints
- 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))
So I create a slicer with the parameter, and I retrieve the value chosen by the user by using SELECTEDVALUE?
The problem is that at this stage, when I do this, the number of rows displayed in my table does not change. It's as if the data is static.
Just as a reminder of my need, I have to disclose all the lines that are part of the 5% of my selection. My request is not to disclose only the value in which the 5% value is.
May I ask you to be more precise on how to use this percentileX because I think I miss something there.
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))
- killer851 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.