Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Another sort by date problem

Hi.

 

Im going crazy trying to just get the date table to be sorted correctly

 

I used this dax:

 

Calendar =
var _calendar = CALENDAR("1/1/2020", "12,31,2023")
return
ADDCOLUMNS(_calendar, "Year", YEAR([Date]), "Month Number", MONTH([Date]),"Month", FORMAT([Date], "mmmm"), "Quarter", "QTR "&FORMAT([Date], "Q"), "Quarter Number", FORMAT([Date],"Q"))
 
But it just wont sort correctly, I sort by column "Month Number" but it keeps starting with the number 7 instead of 1
 
Any ideas?
 

4 Replies

  • Anonymous 

    A quick way to resolve this is to use Power BI generated Date Hierarchy, instead of using newly created columns.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      and how do I do that?

      • MURTAZA's avatar
        MURTAZA
        Resolver I

        Follow these steps:

         

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Your DAX table expression worked fine for me, including the Sort By column.  Please see this article/video on how to create Date tables that don't need to be sorted.  There is one you can copy/paste and use directly.

    No Sort Date Tables! – Hoosier BI

     

    Pat