Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
abraine
Frequent Visitor

How to Sort by Column on a Matrix Visual

I have this Matrix Table that was built. I need it to be sorted most to least recent, as opposed to how it is right now. 

 

I can sort by row if I use the more options button but not by column. Any help is much appreciated. Thank you. 

abraine_0-1741125340502.png

 

1 ACCEPTED SOLUTION
ArwaAldoud
Super User
Super User

Hi @abraine 

Since Power BI does not allow direct sorting of columns in a Matrix, follow these steps:
Option 1: Create a Sort Order Column using RANKX

  1. In Power BI Desktop, go to Data View.
  2. Open the table containing your date column.
  3. Create a new calculated column in DAX:
  4. DAX
    SortOrder = RANKX(
    ALL('YourTable'[DateColumn]),
    'YourTable'[DateColumn],
    ,
    DESC, -- Sort from most recent to oldest
    DENSE -- Ensures continuous ranking
    )
  5. In Modeling → Sort by Column, select DateColumn and sort it by SortOrder.

 

Option 2: Use "Sort by Column" in the Modeling Tab

  1. If your table has a "Week Ending" or "Date" column, make sure it's formatted as a date.
  2. Go to Modeling → Click the DateColumn.
  3. Select Sort by Column → Choose DateColumn (or a numeric sort column if created).
  4. The matrix should now display columns in descending order (most recent first).

Note: If your date hierarchy is enabled in the matrix, try removing the hierarchy and using the raw date column.

 

If this response was helpful, please accept it as a solution and give kudos to support other community members

 

View solution in original post

2 REPLIES 2
ArwaAldoud
Super User
Super User

Hi @abraine 

Since Power BI does not allow direct sorting of columns in a Matrix, follow these steps:
Option 1: Create a Sort Order Column using RANKX

  1. In Power BI Desktop, go to Data View.
  2. Open the table containing your date column.
  3. Create a new calculated column in DAX:
  4. DAX
    SortOrder = RANKX(
    ALL('YourTable'[DateColumn]),
    'YourTable'[DateColumn],
    ,
    DESC, -- Sort from most recent to oldest
    DENSE -- Ensures continuous ranking
    )
  5. In Modeling → Sort by Column, select DateColumn and sort it by SortOrder.

 

Option 2: Use "Sort by Column" in the Modeling Tab

  1. If your table has a "Week Ending" or "Date" column, make sure it's formatted as a date.
  2. Go to Modeling → Click the DateColumn.
  3. Select Sort by Column → Choose DateColumn (or a numeric sort column if created).
  4. The matrix should now display columns in descending order (most recent first).

Note: If your date hierarchy is enabled in the matrix, try removing the hierarchy and using the raw date column.

 

If this response was helpful, please accept it as a solution and give kudos to support other community members

 

lbendlin
Super User
Super User

Add a sort column to your table, sort the dates column by that column.  That will automatically render the column headers in the desired order.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors