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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
160475
Helper I
Helper I

sorting months

dears 

 

i have a chart where the dates are not sorted correctlly, the date data i have are in text form JAN-DEC 

im trying to creat a new column with this DAX: Month number = month(tablename[Month]) so i can sort correctlly but when i create this column it give me this errorr : Cannot convert value 'Jan' of type Text to type Date.

 

160475_0-1647169372367.png

 

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @160475 ,

 

There is a tip to convert Month name to Month number—— combine Month name and " 1" , then change its type to DateTime, finally use MONTH() to get the number:

 

Month Number = MONTH( CONVERT( MAX('Table'[Month]) &" 1", DATETIME))

 

Eyelyn9_0-1647409627500.png

In visuals , you could apply it to Tooltips field , and then sort by it:

Eyelyn9_1-1647409720120.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @160475 ,

 

There is a tip to convert Month name to Month number—— combine Month name and " 1" , then change its type to DateTime, finally use MONTH() to get the number:

 

Month Number = MONTH( CONVERT( MAX('Table'[Month]) &" 1", DATETIME))

 

Eyelyn9_0-1647409627500.png

In visuals , you could apply it to Tooltips field , and then sort by it:

Eyelyn9_1-1647409720120.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@160475 

if you only have the text column, you can try this

Column = SWITCH('Table'[Column1],"Jan",1,"Feb",2,"Mar",3,"Apr",4,"May",5,"Jun",6,"Jul",7,"Aug",8,"Sep",9,"Oct",10,"Nov",11,"Dec",12)

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Vera_33
Resident Rockstar
Resident Rockstar

Hi @160475 

 

Do you have a Date column? Month needs Date, Month number = month(tablename[Date]), even if you use SWITCH to get month number from your current text, it still has a circular dependency error...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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