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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Sashwato
Helper II
Helper II

Top N selection dropdown for report filter

Hello all,

 

I am trying to achieve a report wherein I can filter the Top 5, Top 10, Top 15 based selection from a dropdown or slicer to show the top results of Zip code data based on number of employees. Below screenshot can help understand:

 

Top N image.png

 

If you see above I need something similar like a dropdown or button can also help in this case - Like Top 5 Zip, Top 10 Zips, etc. I would need the selection to basically filter ZIP codes on the entire report.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Sashwato ,

 

Based on your description, I did a test. You can do some similar steps as follows.

1. Create a "Top N" table. (I use the "Enter Data" to create it.) 

2. create a measure and drag it into the filter of the table visual.

Measure = 

var x1=RANKX(ALL('Table'),CALCULATE(MAX('Table'[Value])),,DESC)

var x2=SELECTEDVALUE('Top N'[rank])

return

IF(x1<=x2,1,0)

Result:

032201.gif

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Could you share some data to work with.  Also, please show the expected result there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @Sashwato ,

 

Based on your description, I did a test. You can do some similar steps as follows.

1. Create a "Top N" table. (I use the "Enter Data" to create it.) 

2. create a measure and drag it into the filter of the table visual.

Measure = 

var x1=RANKX(ALL('Table'),CALCULATE(MAX('Table'[Value])),,DESC)

var x2=SELECTEDVALUE('Top N'[rank])

return

IF(x1<=x2,1,0)

Result:

032201.gif

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

VijayP
Super User
Super User

@Sashwato 

You Need to Create Rank Function and Filter the Data based on Rank
You have a Slicer already which is showing 5,10,15 (Zip Codes) and let us assume the Column name of those 5,10,15 etc is [N]
Now use this code
VAR Rank of Zip = RankX(all(Table[Zip]), your measure )
RETURN
calculate(yourmeasure,filter(all(table[zip]),rank of zip <= [N]),distinct(zip))

 

This will give you the required information




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.