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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
k-linerz
New Member

Dynamic Top N

Hello,
Ive got data in power BI pulled from SQL. Columns are : Date, SiteName, PersonName, SalesNumber, What I want to do is have a table to show the Date and then in that show the top 5 PersonName and the Sales Number. Each day will show the different peoples name and the volume. I need it to be dynamic so that If i then select a specific site in the SiteName slicer it will pull the top 5 from that specific site.
Example of outcome 

klinerz_0-1645187152682.png


Ive searched around to find a way to do this but no luck. Any advice? 

Thanks

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @k-linerz 

 

You can try the following methods.

Measure = 
Var _Top5=TOPN(5,ALLSELECTED('Table'[Name]),CALCULATE(SUM('Table'[Sales])),DESC)
Var _name=SELECTEDVALUE('Table'[Name])
Return 
IF(_name in _Top5,1,0)

Put Measure in the Filter of the view and set it equal to 1.

vzhangti_0-1645409802354.pngvzhangti_1-1645409843830.png

Please see the attachment for details.

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-zhangti
Community Support
Community Support

Hi, @k-linerz 

 

You can try the following methods.

Measure = 
Var _Top5=TOPN(5,ALLSELECTED('Table'[Name]),CALCULATE(SUM('Table'[Sales])),DESC)
Var _name=SELECTEDVALUE('Table'[Name])
Return 
IF(_name in _Top5,1,0)

Put Measure in the Filter of the view and set it equal to 1.

vzhangti_0-1645409802354.pngvzhangti_1-1645409843830.png

Please see the attachment for details.

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.