cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bakhtawar Member
Member

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

3 REPLIES 3
CheenuSing Super Contributor
Super Contributor

Re: Sorting order in legend

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!
Bakhtawar Member
Member

Re: Sorting order in legend

how to resolve this
CheenuSing Super Contributor
Super Contributor

Re: Sorting order in legend

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!

Helpful resources

Announcements
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)