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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sort legend by current month value for line chart

Hi there

 

I am struggling to sort a line chart legend by the current month value. The chart needs to show the last 6 months worth of data for a list of packages, the latest package value on the chart I want to align with the legend so it is easier for the reader match the the line to the legend colour.

 
 

I cannot use a manual entry custom sort for the legend because I want the legends order to update automatically depending on the value of the items e.g. highest to lowest - this will be updated monthly for multiple projects.

 

I want the legend to be determined by the value, then create a a relationship between the two tables below so I can use the standardised descriptions as the line chart legend

 

Below example data

ValueDescriptionTypeDateProject NamePackage code
100Package 1Packages30/08/2020A1.0001
200Package 2Packages30/08/2020A1.0002
450Package 3Packages30/08/2020A1.0003
200Package 4Packages30/08/2020A1.0004
250Package 5Packages30/08/2020A1.0005
100Package 1Packages30/07/2020B2.0001
100Package 2Packages30/07/2020B2.0002
200Package 3Packages30/07/2020B2.0003
300Package 4Packages30/07/2020B2.0004
700Package 5Packages30/07/2020B2.0005
50Package 1Packages30/06/2020B2.0001
300Package 2Packages30/06/2020B2.0002
400Package 3Packages30/06/2020B2.0003
500Package 4Packages30/06/2020B2.0004
1,000Package 5Packages30/06/2020B2.0005

 

Package codeStandardised Desc
1.0001Development
1.0002Construction
1.0003Operation
1.0004Comms
1.0005Other
2.0001Development
2.0002Construction
2.0003Operation
2.0004Comms
2.0005Other

 

Using this similar request I have created a summurize query based on the below

https://community.powerbi.com/t5/Desktop/Sorting-legend-by-largest-value/m-p/98855#M41657

 

SummarizePets =
SUMMARIZE ( Table1, Table1[Pet], "Quantity", CALCULATE ( SUM ( Table1[Q] ) ) )

But I dont know how to add the filter for latest month values only, and this adds a third table which I would need to create a relationship with to ensure I can have the Standardised Descriptions as the legend.

 

Help with adding the DAX filter for latest month so I summurise and sort by this data order or other sugguestions would be much appreciated, thank you! 🙂 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can extract the legend fields value to a new table and add the index of these fields with a specific index as you wanted.
Then you can link this field to raw table fields values and use the custom table field on your chart to instead and your graph will display the specific sort order based on the custom table index as you configured.

Custom Sorting in Power BI 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can extract the legend fields value to a new table and add the index of these fields with a specific index as you wanted.
Then you can link this field to raw table fields values and use the custom table field on your chart to instead and your graph will display the specific sort order based on the custom table index as you configured.

Custom Sorting in Power BI 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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