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
Divya904
Helper III
Helper III

DAX Calendar - Date Sorting

Hi All

 

I have created a DAX calculation to generate the calendar Date as given below. After executing this code, i have got a table named 'Date' which has columns: Calendar Date, day, month, year.

I need to sort Calendar day in descending order in my slicer like most recent dates on top. Please let me know how can i do that. Thanks.

 

 

 

Date =
GENERATE (
CALENDARAUTO(),
VAR currentDay = [Date]
VAR day = DAY( currentDay )
VAR month = MONTH ( currentDay )
VAR year = YEAR ( currentDay )
RETURN ROW (
"day", day,
"month", month,
"year", year )
)

1 ACCEPTED SOLUTION

Hi @Divya904

 

It is possible to create a default sort order, but you need to generate a separate column that has negative values for each month and then use the "Sort by Column" feature to set the default order.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

6 REPLIES 6
prateekraina
Memorable Member
Memorable Member

Hi @Divya904,

 

Click on the elipses on the top right corner of the slicer and change sort order to descending.
Capture.PNG

 

Prateek Raina

Hi, I need to create a custom sort in chart for example, it should start from,Oct as 1,Nov as 2,Dec as 3,Jan as 4 soon on...can you please help me on this

Hi Prateek,
Thanks for replying on it.
Can we sort the field instead. So that in all the reports it comes as sorted by default.
Thanks

Hi @Divya904,

 

By default, every field is sorted in ascending order.

As of now, there is no way apart from the earlier approach I told, to modify the sort order in visuals.

 

Once you have changed the sort orders to descedning and then published the report, your users will see it in descending order only so they will not have to again sort as you have done it during report creation.

 

Prateek Raina

Hi @Divya904

 

It is possible to create a default sort order, but you need to generate a separate column that has negative values for each month and then use the "Sort by Column" feature to set the default order.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Phil_Seamark
Employee
Employee

Hi @

 

On the slicer visual, click the three dots in the top right-hand corner, then chose the appropriate sort required.  Be wary that you may need to click the name of the field to sort and then repeat to click the little A/Z icon to the left of the field name to control the sort direction

 

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.