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
Bakhtawar
Post Patron
Post Patron

Sorting order in legend

I tried subburst chart 

and drag year field and enable legend also from properties but this shows that legend is not in order whereas year field is already sorted in data .. i checked it through dragging field in dropdown 

 

now how i sort that legend 

 

check image 

Untitled.png

4 REPLIES 4
CheenuSing
Community Champion
Community Champion

Hi @Bakhtawar ,

 

The legend goes by the  value being plotted than by year. This is true for pie chart also.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

how to resolve this

Hi @Bakhtawar ,

 

I hope you have a calendar table ( date table) .

 

Using Edit Query create a new blank query and paste the following query

 

let
    Source = CalendarTable,
    #"Removed Columns" = Table.RemoveColumns(Source,{"X-AxisName", "SortOrder", "DateKey", "CalendarMonth", "CalMonthName", "CalMonthYearName", "IsCurrentCalYear", "MonthSeqNumber", "IsCurrentMonth", "StartPeriod", "EndPeriod"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"CalendarYear"}, {{"Count", each _, type table [CalendarYear=number]}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Grouped Rows",{"Count"}),
    #"Added Index" = Table.AddIndexColumn(#"Removed Columns1", "Index", 1, 1),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Index",{{"CalendarYear", Int64.Type}})
in
    #"Changed Type"

Replace CalendarTable by your calendar table ( date table ) name

In the RemoVe Columns  remove all columns except the Year from your CalendarTable

Follow the rest of the code.

 

WHat this does is using the calendar ( Date) table it create a table with just the year and index them from 1 to last year in the table.

 

Call this as YearTable.

Close the Eidt Query.

 

Expand the columns of YearTable in the DataView

Click on the YearColumn .

Set the Sort ByColumn  to Index.

 

Using Manage Relationship set a relationship between CalendarTable- Year column with the YearTable - YearColumn

 

Now create a new SunBurst chart.

Put  the YearTable-YearColumn as your legend. Values as your measure.

 

This will work.

 

If you can share the pbix put in Google or OneDrive and paste the link here for me to put this and send back to you.

 

Cheers

 

CheenuSing

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Hello @CheenuSing , I found your explanation very helpful. I am currently facing a similar issue as @Bakhtawar, but I am not enabled to edit queries, as I am using a fixed dataset and the level of interaction I can have with the data is limited. I think it would be very helpful for Power BI users to be able to sort the legend data alphabetically or numerically using the visual headers in sunburst charts. Are you aware of any ways to "ask" microsoft to add this feature and monitor its development? Thank you both, I hope this was the right section to ask this type of question!

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.