Forum Discussion

Divya904's avatar
Divya904
Helper III
8 years ago
Solved

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 )
)

  • Phil_Seamark's avatar
    Phil_Seamark
    8 years ago

    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.

6 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Microsoft 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

     

  • prateekraina's avatar
    prateekraina
    Memorable Member

    Hi Divya904,

     

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

     

    Prateek Raina

    • Divya904's avatar
      Divya904
      Helper III
      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
      • prateekraina's avatar
        prateekraina
        Memorable Member

        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

    • harirao's avatar
      harirao
      Post Prodigy
      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