Forum Discussion

andrerosario's avatar
andrerosario
Regular Visitor
9 years ago
Solved

Stacked graph sort order

Hi!   I have the attached stacked column graph. How can I define a specific order for the columns and for the "series"?   As you can see, the columns are "9; 8_A; 8;11;10", as I have an "8_A...
  • KGrice's avatar
    KGrice
    9 years ago

    The good thing about adding a column in M (Edit Queries) or DAX (Data view) is that once you add the column, it will be there for any new data you import when you refresh the report. As long as you're refreshing and not starting your entire Desktop report from scratch every time, any new columns will be there.

     

    However, you can also do this with the related table. If your main table looks like this (the Scores column is just something to add data in there for the chart later):

     

     

    And your Aux table has unique values and the desired sort order like this:

     

     

    You can create a relationship between them on the Column Values column. Power BI will probably have already created it for you, really. Check in Manage Relationships in the Home tab of the ribbon.

     

     

    With that in place, go to the Data view and add a New Column to the main table.

     

    Sort Order = RELATED(AuxTable[Sort Order])

     

    Use that new column with the Sort By Column feature, and you're good to go. Notice that 8_A in the chart below falls between 8 and 9, based on the sort order provided in the table. Of course, you're still adding a new column with this method, but again, it will be there when you refresh.