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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors