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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
larx_mandel
Frequent Visitor

Matrix order with Date hierarchy

Hi community,

 

I have  matrix table with a Date in a form of hierarchy (Year, Month). In our configuration months are displayed as text.

I create a measure that calculates previous year data:

 

M_PreviousYearData =
CALCULATE(
    SUM(Sales),
    SAMEPERIODLASTYEAR(_mydataset[Date].[Date])
)
 
My table looks like:
 
YearMonthM_PreviousYearData
2024January20
2024February25
...  
2024November50
2024December80
2023January15
2023February40
....  
 
I want to order by Year descending, and then by Month, but matrix only allow to order by Year or Month. If I tried to add a Period to my table, and order by it then my measure stop working, returning BLANK.
 
How can I order to obtain a table like:
YearMonthM_PreviousYearData
2024December80
2024November50
...  
2023December60
2023November30
...  

 

Thanks for your help.

Regards.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @larx_mandel ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a sort order table

vyiruanmsft_2-1738734891799.png

2. Sort the field [Month] of sort order table by the column [Sort Order]

vyiruanmsft_1-1738734863777.png

3. Create the relationship between the sort order table and data table base on the field [Month]vyiruanmsft_0-1738734809622.png

4. Create a table visaul just as shown in the below screenshot

vyiruanmsft_3-1738735286805.png

Sort one column by another column in Power BI - Power BI | Microsoft Learn

Sort a Column with a Custom Order in Power BI - RADACAD

Best Regards

View solution in original post

5 REPLIES 5
larx_mandel
Frequent Visitor

I tried with Shift key but it is not working. It is ordering separately.

My Power BI version is Version: 2.139.1678.0 64-bit (january 2025).

Thanks.

Anonymous
Not applicable

Hi @larx_mandel ,

Please download the latest version of Power BI Desktop and check if you can order multiple fields simultaneously.

Download Microsoft Power BI Desktop from Official Microsoft Download Center

vyiruanmsft_0-1738055460983.png

Best Regards

With new version I have the same behavior. Any other solution to this problem? Thanks.

Anonymous
Not applicable

Hi @larx_mandel ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a sort order table

vyiruanmsft_2-1738734891799.png

2. Sort the field [Month] of sort order table by the column [Sort Order]

vyiruanmsft_1-1738734863777.png

3. Create the relationship between the sort order table and data table base on the field [Month]vyiruanmsft_0-1738734809622.png

4. Create a table visaul just as shown in the below screenshot

vyiruanmsft_3-1738735286805.png

Sort one column by another column in Power BI - Power BI | Microsoft Learn

Sort a Column with a Custom Order in Power BI - RADACAD

Best Regards

Anonymous
Not applicable

Click on the Year column, then after it is sorted by year, hold down the Shift key and click on the Month column

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors