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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
darko861
Resolver II
Resolver II

Line chart legend based on highest values

Hi,

 

I have a line chart that shows the performance of the top 10 members based on the highest number of hours they have consumed over 8 months. The Legend is sorted in alphabetical order but I want it sorted by rank instead (the member with the highest value at the top, in descending order) and keeping the dates in chronological order.

 

darko861_2-1617896712266.png

 

 

What is the easiest way to do this? The values in the chart are based on a measure 

Total Hours = SUM(v_rpt_Time[Billable_Hrs]) + SUM(v_rpt_Time[NonBillable_Hrs])
from the V_rpt_time, which  is the main data source
 
The members are from the table v_rpt_Members and the dates are from the calendar table.
 
All of the tables are related with 1 to many relationships.
 
darko861_1-1617896288133.png

 

If I need to insert a calculated column with a formula, then please advise how and where to insert it? I guess then I would be able to sort by column? If there is a better and more efficient way to do this, then please advise how I should write e.g a new measure or something else in order to get the expected outcome?

 

Thanks in advance!

5 REPLIES 5
jaryszek
Memorable Member
Memorable Member

Up, 

anybody solve the case? 
@darko861 did you replace your visual with different one? 


Best,
Jacek

v-yalanwu-msft
Community Support
Community Support

Hi, @darko861 

 

According to your description,I think you can add a rank column, then merge the rank and member column and name it rank_member,and finally change the legend of the line chart to rank_member. The steps are as follows:
step 1: Add column(rank)

rank =
RANKX (
    'Table',
    MAXX (
        FILTER ( 'Table', [member] = EARLIER ( 'Table'[member] ) ),
        [v_rpt_Time[Billable_Hrs]]] + [v_rpt_Time[NonBillable_Hrs]]]
    ),
    ,
    DESC,
    DENSE
)

step 2: Add column (rank_member)

rank_member =
'Table'[rank] & "-" & 'Table'[member]

v-yalanwu-msft_3-1618286342424.jpeg

step 3:Change legend

v-yalanwu-msft_2-1618286335102.jpeg

 


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

Hi @v-yalanwu-msft , this does not seem to work. I have followed your steps, but you have to remember that your ranking formula is applied to the whole dataset in v_rpt_time data, which means all of the dates from 2019 to 2021. So if I want to showcase a specific date range it does give me the top 10 but it's still in the wrong order since the ranking is not dynamic or applied to that specific date range.

 

darko861_0-1618299806610.png

 

amitchandak
Super User
Super User

@darko861 , I doubt you can sort legend based on Rank. you can only sort by alphabetical order or Sort column.

 

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

Hi @amitchandak, so do you think I should leave it as it is, or is there any other method I could just try, where the members with the highest values are shown first?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.