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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.