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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

date column sorting in a matrix from latest to oldest

Soumya33_1-1595495511297.png

I want to sort the date columns from march2018 to january2018(i.e in desc order), while now it is in ascending order(jan to mar).

Regards,

Soumya

 

 

 

3 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , This for matrix column where you do no have sort option

 

Create a new column like

Month Year = FORMAT([Date],"mmmm-yyyy") // New column because it will always sort desc .
Month Year sort = FORMAT([Date],"yyyymm")
Month Rank = RANKX(ALL('Date'),'Date'[Month Year Sort],,DESC,Dense) // Create desc rank on month sort column or Month Start date

 

Now sort Month Year  on Month Rank  , this will sort desc by default

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

View solution in original post

Hi, @Anonymous 

You can try to enter a table with two columns as below,then make the column "Month_year" sort by index:

7.png


Then  you need to create another column "column" to format the date to "mmmm yyyy" in the raw table

Column = FORMAT(Table1[Date],"mmmm yyyy")

so that you can build relationship between two  tables:

 

8.png

 

After that ,you can create  a Matrix table with a column headers  in a custom order.

9.png

 

pbix attached

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Please refer this existing thread for similar issue:

https://community.powerbi.com/t5/Desktop/Sort-Date-Column-in-Matrix/td-p/602217

 

The above thread suggests using a ranking method based on the following blog:

https://www.excelguru.ca/blog/2018/06/14/ranking-method-choices-in-power-query/

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

5 REPLIES 5
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Please refer this existing thread for similar issue:

https://community.powerbi.com/t5/Desktop/Sort-Date-Column-in-Matrix/td-p/602217

 

The above thread suggests using a ranking method based on the following blog:

https://www.excelguru.ca/blog/2018/06/14/ranking-method-choices-in-power-query/

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Anonymous , This for matrix column where you do no have sort option

 

Create a new column like

Month Year = FORMAT([Date],"mmmm-yyyy") // New column because it will always sort desc .
Month Year sort = FORMAT([Date],"yyyymm")
Month Rank = RANKX(ALL('Date'),'Date'[Month Year Sort],,DESC,Dense) // Create desc rank on month sort column or Month Start date

 

Now sort Month Year  on Month Rank  , this will sort desc by default

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

Anonymous
Not applicable

Thanks Amit  for your reply,

But the column in the matrix is still from oldest date and june2020 is at the end near the total value. while jan2018 is at the beginning.

My source is a sql query, I even tried to add a column with rank of month and tried to sort the column, but the matrix is not changing its order.

 

Regards

 

Hi, @Anonymous 

You can try to enter a table with two columns as below,then make the column "Month_year" sort by index:

7.png


Then  you need to create another column "column" to format the date to "mmmm yyyy" in the raw table

Column = FORMAT(Table1[Date],"mmmm yyyy")

so that you can build relationship between two  tables:

 

8.png

 

After that ,you can create  a Matrix table with a column headers  in a custom order.

9.png

 

pbix attached

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Anonymous
Not applicable

This is working if I Have month-year format, but when I have only year in column, it is not working. 

Still thanks for your help.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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