cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UncleLewis
Super User
Super User

Sort Calculated Column In Date Table

Hi,

I have a fairly standard Date Table in my Model
The one item a bit unconventional is a calculated column that returns a single character for the Month Name unless the month is Jan then return single character and Year like this J2023

All well and good, everything in the Calc Column look correct.
The problem is when I try to use the Abbreviated Name as the X Axis it is in the wrong order

I tried sorting by the Date Column and the DateKey column, but I get the message, "Cannot sort becuase there can be more than one value..."

What can I do to get the xaxis to show in the correct order?

Here's the DAX for my Calc Column

MonthNameAbbr =
VAR __MonthNbr = Month('DateTable'[Date])
VAR __MonthName = FORMAT( DateTable[Date], "MMMM")
VAR __Year = FORMAT( DateTable[Date], "YYYY")
VAR __MonthNameAbbr = CONCATENATE(
                        LEFT(__MonthName, 1),
                        REPT(UNICHAR(8203),__MonthNbr)
                    )
RETURN
    IF(
        __MonthNbr = 1,
        CONCATENATE(CONCATENATE(__MonthNameAbbr,UNICHAR(10)),__Year),
        __MonthNameAbbr
    )
 
Thanks,
-w
1 ACCEPTED SOLUTION
grantsamborn
Impactful Individual
Impactful Individual

Hi @UncleLewis 

If you have a [MonthNo] column in 'DateTable', try sorting by that.

View solution in original post

2 REPLIES 2
UncleLewis
Super User
Super User

Thanks grantsamborn,

That solved it - good to go.

Thanks,

-w

Line Chart.png

grantsamborn
Impactful Individual
Impactful Individual

Hi @UncleLewis 

If you have a [MonthNo] column in 'DateTable', try sorting by that.

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors