Forum Discussion

Bakhtawar's avatar
Bakhtawar
Post Patron
7 years ago

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 

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Bakhtawar ,

     

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

     

    Cheers

     

    CheenuSing

      • Anonymous's avatar
        Anonymous
        Not applicable

        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