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
Cathryn
Helper III
Helper III

Date table - can't sort other columns by date Getting error

Hi All

 

I am so stuck on this.  I created a date table with the code below but when I try to sort the Month column by the date so my dates show up in the correct order in charts, I get the error:

 

"We can't sort the 'Month' column by 'Date'.  There can't be more than one value in 'Date' for the same value in 'Month'.  Please choose a different column for sorting or update the data in 'Date'"

 

All the dates are unique so I can't figure out what else to do.

 

Calendar = var _caledndar = calendar("1/1/2019","12/31/2025") return ADDCOLUMNS(_calendar, "Year", YEAR([Date]), "MonthNumber", MONTH([Date]), "Month", FORMAT([Date], "mmm"))
 
The calendar code was copied from "Guy in a Cube"
 
How else can I sort the date table?
 
Cathryn

 

 

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @Cathryn , 

Did you want to get result like below?

707.PNG

If so, you could set "sort by " on Month like below

709.PNG

710.PNG

Best Regards,
Zoe Zhi

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

4 REPLIES 4
parry2k
Super User
Super User

@Cathryn you should sort Month column by Month Number instead of date column

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you.  I tried your suggestion and it didn't work when I tried to then sort in my charts by year and then month.  

 

But, I recreated the calendar table in a previous version of my pbix file and it created the date hierarchy for me and using that, it showed the months and years in order.

 

Thank you so much for your quick response.

 

Cathryn

dax
Community Support
Community Support

Hi @Cathryn , 

Did you want to get result like below?

707.PNG

If so, you could set "sort by " on Month like below

709.PNG

710.PNG

Best Regards,
Zoe Zhi

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

 

@Cathryn I'm bit lost, it should be super straight forward. Can you share your pbix file and share what is not working? seems like I'm missing something, if you have sensitive info in the file, please remove that before sharing. If you cannot share files here, my email is in the signature, please send me directly.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.