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

Get Fabric certified for FREE! Don't miss 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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.