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
agusti_oliveres
Frequent Visitor

How to sort a date-type slicer in descending order

Hi,

I have a normal slicer with a date-type field, with month granularity. By default, the months are sorted by ascending order (from the older months at the top to the current ones at the bottom), but I would like to sort it in descending order. I have not been able to figure out how to do it. Can anyone help me with that?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Is it simply the months you want in reverse order?  For example you are showing a slicer with December, November etc?

 

If thats the case, you will need a date table and a sort column.

 

If you have a date table already, GREAT!  If not you will need to make one, which is fairly easy.

 

Once you have that, you should have a column with the Month Name and the Month Number.  This Month Name will be the column for your slicer.

 

Next you need a calculated column called "Month Sort" and its formula will be to take the month number and make 12 = 1, 11 = 2 etc.  We can do that with math by doing:

Month Sort = 13 - [Month Number]

Lastly, select your Month Name column and in the ribbon under "Modelling" select 'Sort By Column' and choose your Month Sort.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Is it simply the months you want in reverse order?  For example you are showing a slicer with December, November etc?

 

If thats the case, you will need a date table and a sort column.

 

If you have a date table already, GREAT!  If not you will need to make one, which is fairly easy.

 

Once you have that, you should have a column with the Month Name and the Month Number.  This Month Name will be the column for your slicer.

 

Next you need a calculated column called "Month Sort" and its formula will be to take the month number and make 12 = 1, 11 = 2 etc.  We can do that with math by doing:

Month Sort = 13 - [Month Number]

Lastly, select your Month Name column and in the ribbon under "Modelling" select 'Sort By Column' and choose your Month Sort.

Hi i got your logic see now i got here a question lets suppose there are two years 2022/12/31 and 2023/2/25 now will this logic wont help.can you provide me an alternate solution

I tried to do this with date using a calculated column like this.

SortOrderDateDesc = - DATEDIFF('DateDim'[date_natural].[Date], date(9999, 12, 31), DAY)

 

But when I try to sort the slicer on the date_natural column, I get error:

"Sort by another column. This column can't be sorted that is already sorted, directly or indirectly, by this column".

 

Any suggestions?

I tried to do this with date using a calculated column like this.

SortOrderDateDesc = - DATEDIFF('DateDim'[date_natural].[Date], date(9999, 12, 31), DAY) 

 

But when I try to sort the slicer on the date_natural column, I get error:

"Sort by another column. This column can't be sorted that is already sorted, directly or indirectly, by this column".

 

Any suggestions?

I tried to do this with date using a calculated column like this.

SortOrderDateDesc = - DATEDIFF('DateDim'[date_natural].[Date], date(9999, 12, 31), DAY) 

 

But when I try to sort the slicer on the date_natural column, I get error:

"Sort by another column. This column can't be sorted that is already sorted, directly or indirectly, by this column".

 

Any suggestions?

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.