This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreGet Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.
Power BI’s Matrix visual is a powerful tool for analyzing and comparing data. However, many users face a common challenge—getting months and dates to display in the correct descending order. If you’ve ever seen January show up before December, you know how frustrating this can be!
In this blog, we’ll explore a step-by-step method to fix this issue and ensure your date columns always sort correctly.
The first step is to set up a dedicated Date Table. This table is essential for sorting and filtering in Power BI. Make sure your Date table includes:
Day
Month Name
Month Number
Having these columns gives you flexibility in creating sort logic later.
Next, create a column called Date Sort. This ensures each date aligns with the proper month-end value.
DAX:
Date Sort = (ENDOFMONTH('Date'[Date]) - ('Date'[Day])) + 1
This works by:
Taking the last day of the month (ENDOFMONTH)
Subtracting the day number
Adding +1 to realign the dates
Even with Date Sort, sorting across years can still be tricky. That’s where the Month Sort column comes in.
DAX:
Month Sort = INT(
YEAR('Date'[Date]) & 13 - MONTH('Date'[Date Sort])
)
This approach:
Combines Year and Month values
Uses a small trick (13 - MONTH) to flip the order
Ensures months are sorted correctly across multiple years
Finally, create a DateKey column to establish relationships with your fact tables.
DAX:
DateKey = INT(FORMAT([Date Sort], "DDMMYYYY"))
This helps maintain accuracy when connecting your Date table with other tables.
Sorting dates in Power BI Matrix visuals doesn’t have to be a headache. By:
Creating a Date Table
Adding a Date Sort column
Refining with a Month Sort column
Building a DateKey for relationships
With these steps, your Power BI Matrix will always present dates in the correct descending order, keeping your reports clean, accurate, and professional.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.