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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Sort custom text date range on x axis

Hi Everyone,

I've been stuck on this for awhile. I've tried creating a separate calendar table to have the following columns:

  • Date (Based on min and max of my fact table)
  • Month Week Range (a column that shows the week range in terms of the month it's in ie 8/1/2022-8/7/2022
  • Week Num (WeekNum(Calendar[Date])

I've read multiple posts saying to order a custom text date range, i'll need to have another column that I can use in the Sort By Column functionality. I'm just having trouble uniquely identifying these columns in a way that they sort properly. I always get an issue where it says "Cannot sort Month Week Range by Week Num because there can't be more than one value in Week Num for the same value in Month Week Range." I think I understand that there are multiple Week Nums to the Month Week Range, but I'm not sure how to resolve this issue.

 

Incorrect week order:

skedis_1-1660199872738.png

 

Correct week order:

skedis_2-1660199975420.png

 

Many thanks in advance!

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your dataset looks like, but one of ways is to create the sort column by using the date that is mentioned in the front of the range, like the below picture and the attached pbix file.

And then, the range column can be set to be sorted by the Sort column.

 

I suggest creating this in Power Query Editor. The attached file shows how to to this in Power Query Editor.

Please check the attached file.

 

Picture1.png

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your dataset looks like, but one of ways is to create the sort column by using the date that is mentioned in the front of the range, like the below picture and the attached pbix file.

And then, the range column can be set to be sorted by the Sort column.

 

I suggest creating this in Power Query Editor. The attached file shows how to to this in Power Query Editor.

Please check the attached file.

 

Picture1.png

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Thank you so much @Jihwan_Kim ! You are not only a super user haha but my super hero. Ty ty.

 

May I ask why you are suggesting to do this in Power Query editor opposed to DAX? 

Hi,

Thank you for your message. 🙂

One of reasons is that if I do this by writing DAX, 

 - I have to extract the date information (or a ranking number information) from the existing range column in order to create a sort column. In this case, the sort column is depending on the range column. I think this may cause circular dependency. I think there is a way not to cause a circular dependency, but in my opinion, the easiest way is to create a sort column in Power Query Editor.

I hope this explains well.

Thank you very much.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

October NL Carousel

Fabric Community Update - October 2024

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