Forum Discussion

taylororiger's avatar
taylororiger
Helper II
4 years ago
Solved

Adjusting Columns/Rows Sort Order

I have these "Years as EL" in those groups.  Is there a way to display those in the correct order? (5-9 should be after 0-4, for example).  I have this issue with a few tables where the sorting needs to be rearranged.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi taylororiger,

    According to your description, it sounds like you want to achieve 'custom sort' effect. If that is the case, you can refer to the following link to create a custom sort table with sort order and set the 'sort by column' property.
    Then you can link it to the raw table field and use new table fields on the matrix to replace the old one to apply for new sorting order.

    Custom Sorting in Power BI 
    Regards,

    Xiaoxin Sheng

10 Replies

  • To get the custom order in the desired way:

     

    a) You need to have a dimension table and have a column to denote the sort order.

        Say "Years as EL - Sort Order" , and you can hide this column for report view

        Select the column "Years as EL" and then assign the "Sort by Column"
        "Years as EL"          "Years as EL - Sort Order"
        0-4                             1
        5-9                             2

       ... 

     

    Rough idea, how it will look after the above steps:
     

     

     

    b) refresh the chart, if it is not refreshed already

      • sevenhills's avatar
        sevenhills
        Super User

        In the home tab, create a table using 

         

         

        My bad, Dimension table is a concept and you dont see it on any menu. Lookup or dimension table are data concepts. 

  • PijushRoy's avatar
    PijushRoy
    Community Champion

    Hi taylororiger 

    Create a Calculated Column with below DAX
    Sort Col= VAR _yearsasel = SELECTEDVALUE(Table'Years as EL')
    SWITCH(
    TRUE(),
    _yearsasel = "0-4",1,
    _yearsasel = "5-9",2,
    _yearsasel = "10-14",2,
    so on

    Click the column YEARS AS EL and select SORT BY from ribbon and select new calculated column.
    In the visual, 3 dot, Sort by YEARS AS EL and acceding order

    If you have any question, please let me know.
    If solve your requirement, please mark this answer as SOLUTION
    If this comment helps you, please LIKE this comment/Kudos

    Other option you can follow - https://community.powerbi.com/t5/Desktop/quot-Sort-by-column-quot-from-a-related-table/m-p/89265#M37509