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
skedis
Helper I
Helper I

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.


Go to My LinkedIn Page


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.


Go to My LinkedIn Page


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.


Go to My LinkedIn Page


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.