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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
UncleLewis
Responsive Resident
Responsive Resident

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
Responsive Resident
Responsive Resident

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.