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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
rintoalappat
Frequent Visitor

Top N Legend on a Time series Line chart with field parameter

Hi all,

 

I'm having a difficult time to show Top 5 Legend based on a Year-Month Trend Chart with a Field Parameter.

 

Data I have :

Field Parameter : Dim 

             Values (Region , Customer)

Slicers : Market, Segment, Category

Line Graph : Year Month on X-axis 

Sum of Sales on Y-axis

Field Parameter on Legend

 

Expectation :

1, Showing Top 5 based on "Profit" when selecting Field Parameter "Customer", should show everything when selecting "Region". 

 Note : on line graph, we are ploting "Sales" measure but Top N needs to find based on "Profit"

2, Slicers should affect the top 5

3, For below selection line should show trend of "first 5 people from the table"

 

rintoalappat_0-1706855417146.png

 

Download the above PBIX file : Click Here

 

Appreciate if someone crack this fast as we are having a PBI Migration. 

 

Regards,

Rinto

3 REPLIES 3
Anonymous
Not applicable

Hi @rintoalappat 

 

I'm sorry I can't open your link. If your problem hasn't been solved yet, please provide detailed sample data:  How to provide sample data in the Power BI Forum - Microsoft Fabric Community . Or show it as a screenshot. Please remove any sensitive data in advance. 

 

Best Regards,
Community Support Team _Yuliax

 

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

 

 

 

amitchandak
Super User
Super User

@rintoalappat , Create region sale

Region sales = calculate(sum(Orders[Sales]), Filter(ALLSELECTED(Orders), Orders[Region]= max(Orders[Region])))

 

Then use this measure in visual

Switch Sales = var _selected = maxx(FILTER('Select Dim', 'Select Dim'[Select Dim Order] = SELECTEDVALUE('Select Dim'[Select Dim Order])), 'Select Dim'[Select Dim])
return
Switch( _selected,
"Customer", sum(Orders[Sales]),
"Region",CALCULATE(Sum(Orders[Sales]), KEEPFILTERS(TOPN(5, ALLSELECTED(Orders[Region]),[Region sales],DESC))))

amitchandak_0-1706857199594.png



File is attached



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

Thank you and appreciate you time on this solution. 

 

I was trying and found there are few more steps: (please check the highlighted)

 

1, Showing Top 5 based on "Profit" when selecting Field Parameter "Customer", should show everything when selecting "Region". 

 Note : on line graph, we are showing "Sales" measure but Top N needs to find based on "Profit"

 

I missed to enter this in my first post.  Could you please try with this modification and let me know. Thanks in advance

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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