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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sjpbi
Frequent Visitor

How to filter table based on rank measure?

Hi I have an issue filtering my table based on rank value, I have this scenario:

 

When the user select a sample size %, the table should filter based on the rank (data_filter measure) 

  • Total Data count = total unique ids
  • For data_filter = 15% selected by user multiply by total data count =2.7 (round up)=3
  • data_filter in table= rank based on created calculated column randomrow=rand()

 

sjpbi_0-1698216931801.png

 

My expected should be like this when user select a sample size, the table will automatically filter based on random selected %

 

sjpbi_1-1698217162207.png

 

Hope someone will help. Thanks

 

 

10 REPLIES 10
Anonymous
Not applicable

Hi @sjpbi ,

 

Try expression below:

data_filter = RANKX(ALLSELECTED('Table'[RandonRows]),CALCULATE(SUM([RandonRows])),,DESC,Dense)
For data_filter = CALCULATE(ROUND([Total Data count]*[% Value],0),ALLSELECTED('Table'[RandonRows]))
For visual = IF('Table'[data_filter]<='Table'[For data_filter],1,0)
RandonRows = RAND()
Total Data count = SUM('Table'[Data Count])
 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

sjpbi
Frequent Visitor

  • data_filter  is a measure in a table with this formula  RANKX(ALLSELECTED(tablename),sum(randomrow),,ASC)

I'm still getting all 0's

 

sjpbi_0-1698303014160.png

 

 
 
Anonymous
Not applicable

Hi @sjpbi ,

 

Please try to add All(your table) to the for_data_filter expression

 

Best regards,
Community Support Team_ Scott Chang

 

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

below is my formula for For data_filter 

sjpbi_0-1698304282018.png

 

Anonymous
Not applicable

Hi @sjpbi ,

 

please try this expression:

For data_filter = CALCULATE(ROUND([Total Data count]*[% Value],0),ALL('Table'))

 

can't use ALL since i have other filters in the report.

 

  • For data_filter = ROUND([Total data count]*[%selected],0)
  • RandomRow = rand()
  • For visual = IF([data_filter]<=[For data filter],1,0)
  • data_filter = RANKX(ALLSELECTED(tablename),sum(RandomRow)],,ASC)
     
    Still unable to display 1s and 0s in For visual, so it can be filtered to 3 rows only
     sjpbi_1-1698306556116.png

     

     

 

sjpbi
Frequent Visitor

Actually the data filter column is the rank measure of random row column i created and sort out to asc the table data should filter based on the total count * %value selected by user so the table will display top 18 counts

Anonymous
Not applicable

Hi @sjpbi ,

 

Based on your description, I created simple samples and you can check the following results:

vtianyichmsft_0-1698289843874.png

 

For data_filter = ROUND([Total Data count]*[% Value],0)

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

Data should filter only 3 rows  since it's 18*15%=2.7=3

Anonymous
Not applicable

Hi @sjpbi ,

 

I'm trying to create a measure for the filter to filter out columns with a value of 1,and getting the result:

vtianyichmsft_0-1698301081969.png

 

For visual = IF('Table'[data_filter]<='Table'[For data_filter],1,0)

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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