Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
UncleLewis
Helper V
Helper V

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
Solution Sage
Solution Sage

Hi @UncleLewis 

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

View solution in original post

2 REPLIES 2
UncleLewis
Helper V
Helper V

Thanks grantsamborn,

That solved it - good to go.

Thanks,

-w

Line Chart.png

grantsamborn
Solution Sage
Solution Sage

Hi @UncleLewis 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.