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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
v-yuaj-msft
Community Support
Community Support

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/
v-yuaj-msft
Community Support
Community Support

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.