Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Sorting Months

First time using a Date Table because I keep hearing I should. Unfortunately visuals are sorting Month names alphabetically. To try and get around that I have added the Month Number to my Date Table. Unfortunately even that is sorting alphabetically. How in the world can get the months to simply appear in the order in which they occur? 

 

Example of what is happening:

Apr, August, ...

Month #:

1, 10, 2, 3,...

 

Desired Result:
January, February..

 

Month#:
1, 2, 3...

 

Screenshots of the problems:

 

 

 

 

Here is the DAX I have used/modified trying to get the Date table to cooperate:

DateTable =

ADDCOLUMNS (

CALENDAR (DATE(2023,01,01), DATE(2023,12,31)),

"Year", YEAR ( [Date] ),

"Month", FORMAT ( [Date], "MMM" ),

"Month Number", FORMAT ( [Date], "M" ),

"Weeks",

"Week"&

VAR _WN = WEEKNUM([Date],1)

RETURN

IF(

_WN>52,

5,

IF(

MOD( _WN,4)=0,

4,

MOD( _WN,4)

)

),

"Days",FORMAT ( [Date], "DDDD" )

)



 

  • Hi Anonymous 
    After adding the month number, you need to modify the sort order of months names by these numbers:

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

1 Reply

  • Hi Anonymous 
    After adding the month number, you need to modify the sort order of months names by these numbers:

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly