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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
shiex1
Frequent Visitor

Sort by the value that contains date

Hello everyone,

 

I wonder if anyone could please help me understand how to sort the data by "week of" so that it's in order of the date. This "week of" field is a column that concatenated string "week of " and date column. I sorted it by "week off" column in ascending. But it seems that week of 4/5/2021 is out of place. Does this mean that the sort on "week of" shouldn't work the way I need it and it just happen to sort everything in order except "week of 4/5/2021", or I should be able to sort in this way and something is wrong here. The column "week of" is created as quick measure. It's not from power query.

 

shiex1_0-1651257077224.png

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @shiex1 ,

The first thing to make clear is that [week of] is a Text type field, and as @HotChilli said, the sorting((alphabetically)) is correct. If you want that [week of] field to be sorted by the date in it, you might consider changing the format of the [week of] field to the format in Table2 in the figure below. This will give you the sorting results you expect... yingyinr_0-1651645366856.png

If the field [week of] is a calculated column, you can update its formula as below:

 

week of = "Week of "&FORMAT('Table'[Date],"MM/DD/YYYY")

 

yingyinr_1-1651645776531.png

Or you can select the field [week of] and navigate to Column tools ribbon to Sort by Column the field [Date]...

yingyinr_2-1651645909496.png

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @shiex1 ,

The first thing to make clear is that [week of] is a Text type field, and as @HotChilli said, the sorting((alphabetically)) is correct. If you want that [week of] field to be sorted by the date in it, you might consider changing the format of the [week of] field to the format in Table2 in the figure below. This will give you the sorting results you expect... yingyinr_0-1651645366856.png

If the field [week of] is a calculated column, you can update its formula as below:

 

week of = "Week of "&FORMAT('Table'[Date],"MM/DD/YYYY")

 

yingyinr_1-1651645776531.png

Or you can select the field [week of] and navigate to Column tools ribbon to Sort by Column the field [Date]...

yingyinr_2-1651645909496.png

Best Regards

Thanks for the details and appologize for the late update. But this solution worked for me just now. Thanks again!

HotChilli
Super User
Super User

It has sorted correctly (alphabetically), it's just not what you want.

You should be able to use 'Sort by Column' feature, using the original date as the other column

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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