Forum Discussion

ShrimpSurf's avatar
ShrimpSurf
Icon for Helper II rankHelper II
4 years ago
Solved

How to Reverse Sort of Column Headers

How do you reverse the sort of column headers?   In my example the sort is from 2018 to 2022.  I would to go from most recent year to oldest.   Help please!

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi ShrimpSurf 

    You can create a conditional column to add a reverse index .

    (1)Add a conditional column in Power Query .Set year 2022=1,2021=2…

    (2)Go back to Desktop view, and choose the column [year] ,sort by the conditional column .

    The final result is as shown :

    I have attached my pbix file , you can refer to it .

     

    Best Regard

    Community Support Team _ Ailsa Tao

7 Replies

    • bcdobbs's avatar
      bcdobbs
      Icon for Community Champion rankCommunity Champion

      Thanks Anonymous, that'll teach me to reply from memory! Had to boot laptop up to check but yes 100% correct you do have to trick it with a sort order column.

       

      Have a great new year.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Haha bcdobbs  definitely seems like one of those things that should be possible, but still has to be "hacked" ☹️.

         

        Thanks, you too!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ShrimpSurf 

    You can create a conditional column to add a reverse index .

    (1)Add a conditional column in Power Query .Set year 2022=1,2021=2…

    (2)Go back to Desktop view, and choose the column [year] ,sort by the conditional column .

    The final result is as shown :

    I have attached my pbix file , you can refer to it .

     

    Best Regard

    Community Support Team _ Ailsa Tao

  • bcdobbs's avatar
    bcdobbs
    Icon for Community Champion rankCommunity Champion

    If you click on the visual 3 dots should appear (normally top right). It should give you options on sorting.

  • aj1973's avatar
    aj1973
    Icon for Community Champion rankCommunity Champion

    Hi ShrimpSurf 

    In the table where field date/year is, add a column where you rank the years descending, like 2022 equals 1, 2021 equals 2 , 2020 equals 3.... Once the column is added go back to the field in the report and sort it by 

    the name of the new added column.

     

  • ced1971's avatar
    ced1971
    Frequent Visitor

    To avoid creating a static table to sort years I would create a new column being 2100 - [Year] and simply sort on that new integer value