Forum Discussion

jmfillman's avatar
jmfillman
Helper I
1 year ago
Solved

DAX Table Sorting Months

I am creating a date table with the below, but whenever I drop this into a Matrix displaying columns of Fiscal Year, Quarter, and Month, the Months are in alphabetic order by quarter instead of month order and I cannot figure out how to get the Matrix to display in the correct order.

Date Calendar =
    VAR _today = TODAY()
    VAR _quarterStart = DATE ( YEAR ( _today ), ROUNDUP ( DIVIDE ( MONTH ( _today ) -1, 3 ), 0 ) * 3 - 2, 1 )
    VAR _quarterEnd = EOMONTH(_quarterStart, 17)
    VAR _calendar = CALENDAR(_quarterStart, _quarterEnd )
       
    RETURN

        ADDCOLUMNS(
            _calendar,
            "Sort Column", FORMAT( [Date] , "Fixed"),
            "Fiscal Year", YEAR( EDATE([Date],6) ),
            "Fiscal Month", FORMAT( [Date] , "mmm"),
            "Fiscal Quarter", "Q" & QUARTER( EDATE([Date],6) )
        )

15 Replies