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))
Hi Ibendlim,
Firstly, thanks for your explanations but for me it seems to cover only the part regarding the random selection which is not the tricky part.
Regarding the second part, for which I tried to let the possibility to my user to choose its percentage of lines selected based on a filter or slicer. I still don't know how to manage it with your propsal of using simple filter or PERCENTILEX.
Would you please help me by clarifying it?
Thank you,
- lbendlin1 year agoSuper User
How can I create a random sample that dynamically changes the number of rows displayed in the report based on the user’s selected percentage (4%, 5%, 6%, 7%, 8%, or 9%)?So for the case when the user selects 5% you would then only accept the rows that fall in the .05 percentile. and so on.
- killer851 year agoRegular Visitor
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.- lbendlin1 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))