Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Create Random Sample table based on user Productivity

Hello guys

 

i have productivity table for all users as below

image.png 

 

 

 

 

 

 

 

 

 

 

 

 

 

and i create calculated measure 3% like "sample = COUNT(productivity_table[ID No])*0.03" by username

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I want to create output random table based on total sample ( 3% of productivity ) by username like ;
username "nadyan" must have '2' (Based on sample 3% column in total sample table) random sample case,
so i want to get only 2 row data in Productivity table  wich handled by nadyan
so are "fiegata" and any other user

image.png

 

 

 

 

 

 

 

FYI, my connection is on "Directquery" mode to SQL,

i tried to used "Rand()" and "Sample()" for this case but the results are not as expected.

 

Please can you help me to solve this.

 

Thank you 
Regards

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

I created the data:

v-yangliu-msft_0-1622454647009.png

Here are the steps you can follow:

1. Create measure.

Count_measure = COUNTX(FILTER(ALL('Table'),MAX('Table'[Username])='Table'[Username]&&'Table'[ID NO]>MAX('Table'[ID NO])),'Table'[Gen ID])
Result =
IF(MAX('Table'[Sample])>=[Count_measure]&&NOT(ISBLANK([Count_measure])),1,0)

Result:

v-yangliu-msft_1-1622454647016.png

2. Place Measure[Result] in Filter, set is =1, apply filter.

v-yangliu-msft_2-1622454647017.png

3. Result:

v-yangliu-msft_3-1622454647018.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi  @Anonymous ,

I created the data:

v-yangliu-msft_0-1622454647009.png

Here are the steps you can follow:

1. Create measure.

Count_measure = COUNTX(FILTER(ALL('Table'),MAX('Table'[Username])='Table'[Username]&&'Table'[ID NO]>MAX('Table'[ID NO])),'Table'[Gen ID])
Result =
IF(MAX('Table'[Sample])>=[Count_measure]&&NOT(ISBLANK([Count_measure])),1,0)

Result:

v-yangliu-msft_1-1622454647016.png

2. Place Measure[Result] in Filter, set is =1, apply filter.

v-yangliu-msft_2-1622454647017.png

3. Result:

v-yangliu-msft_3-1622454647018.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi  @Anonymous ,

I created the data:

v-yangliu-msft_0-1622188243148.png

Here are the steps you can follow:

1. Create calculated column.

Column = COUNTX(FILTER('Table',EARLIER('Table'[Username])='Table'[Username]&&'Table'[ID NO]>EARLIER('Table'[ID NO])),'Table'[Gen ID])

2. Create calculated table.

Table 2 =
FILTER('Table','Table'[Sample]>='Table'[Column]&&NOT(ISBLANK('Table'[Column])))

3. Result.

v-yangliu-msft_1-1622188243152.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Need help

Anonymous
Not applicable

HI @Anonymous 

 

thanks for your help, but ican't follow this step

 

1. Create calculated column.

image.png

there is no Countx Option, probably its because im using "direct query" mode in connection.

is there any other way to solve it.

thank you

amitchandak
Super User
Super User

@Anonymous , the expected output is not clear. Can you explain that with an example 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak 

 

reffering to "total sample" table, the example like this ;

 

username "nadyan" must have '2' (Based on sample 3% column in total sample table) random sample case,
so i want to get only 2 row data in Productivity table  which handled by nadyan

so are "fiegata" and any other user, 
image.png


 

 

 

 

Thanks for your help.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors