cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Sort a matrix without adding the column

I have the following Matrix :

My measure is like below :

Total_Sales = SUMX ( FactSales, FactSales[SalesQuantity] * FactSales[UnitPrice] )

and my DimDate contains :
• CalendarMonthLabel
• CalendarYear
• CalendarMonthNumber which enables me to sort the result

How can I sort the matrix based on the CalendarMonthNumber and displaying only the CalendarMonthLabel ?

1 ACCEPTED SOLUTION
Super User

Hi @BedhiafiAmira

As I saw, your month now sort as per Alphabetic order
So you need to create a calculated column in your DimDate table, please change DAX as per your month column name

``````MONTH_SORT =
Switch(
True(),
Month = "January",1,
Month = "February",2,
Month = "March",3,
Month = "April",4,
Month = "May",5,
Month = "June",6,
Month = "July",7,
Month = "August",8,
Month = "September",9,
Month = "October",10,
Month = "November",11,
Month = "December",12)
``````

I used calendar month scquence, if your year start from June, so you need to put June as 1

Then click on your MONTH column and select SORT_MONTH column

Now click on table matrix visual change sory by month column

If this comment helps you, please LIKE this comment/Kudos

4 REPLIES 4
Super User

Hi @BedhiafiAmira

As I saw, your month now sort as per Alphabetic order
So you need to create a calculated column in your DimDate table, please change DAX as per your month column name

``````MONTH_SORT =
Switch(
True(),
Month = "January",1,
Month = "February",2,
Month = "March",3,
Month = "April",4,
Month = "May",5,
Month = "June",6,
Month = "July",7,
Month = "August",8,
Month = "September",9,
Month = "October",10,
Month = "November",11,
Month = "December",12)
``````

I used calendar month scquence, if your year start from June, so you need to put June as 1

Then click on your MONTH column and select SORT_MONTH column

Now click on table matrix visual change sory by month column

If this comment helps you, please LIKE this comment/Kudos

Frequent Visitor

I had to use another calculated column :

MonthNameToBeUsedInSorting = DimDate[CalendarMonthLabel]
As I was using month name in creating the sort column I can not use that as a sort column
Frequent Visitor

I am getting a circular dependency when I try to sort the month by the calculated column.

Super User

from the table view select the month label column and click on "sort by column". From the drop down list select "month number".

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.