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
YunJ
Post Prodigy
Post Prodigy

How to sort date column(have multiple same value)

Hi,

I'm wondering is there any method to sort "Date Range" column?

Please kindly find the pbix file:

https://www.dropbox.com/s/s9da9ce3jimw1ko/Date.pbix?dl=0

Capture2.PNG

Capture.PNG

 
3 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @YunJ ,

 

I would replace that column by another one see below codes for DAX and Power query:

 

Power Query:

Date.ToText([Start], "yyyy/MM/dd") & "-" &Date.ToText([End], "yyyy/MM/dd")

DAX:

FORMAT(Sheet2[Start];"yyyy/mm/dd") & "-"&FORMAT(Sheet2[End];"yyyy/mm/dd")

 

This will give you the dates with double digits in month and day so the order should be correct.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Hi @YunJ,

 

You need to have double digits on both day and month in order to get 01-01 otherwise the order will be incorrect change your format from M/D to MM/DD should do the trick


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Hi @YunJ ,

 

Please try like this:

Rank Start = RANKX(Sheet2,Sheet2[Start],,ASC,Skip)

 1.gif

 

Best Regards,
Xue Ding
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

5 REPLIES 5
MFelix
Super User
Super User

Hi @YunJ ,

 

I would replace that column by another one see below codes for DAX and Power query:

 

Power Query:

Date.ToText([Start], "yyyy/MM/dd") & "-" &Date.ToText([End], "yyyy/MM/dd")

DAX:

FORMAT(Sheet2[Start];"yyyy/mm/dd") & "-"&FORMAT(Sheet2[End];"yyyy/mm/dd")

 

This will give you the dates with double digits in month and day so the order should be correct.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

I wrote the DAX as following:

Capture.PNGCapture2.PNG

But the x-axis order is not in the correct sort.

Thanks for your time.

Hi @YunJ ,

 

Please try like this:

Rank Start = RANKX(Sheet2,Sheet2[Start],,ASC,Skip)

 1.gif

 

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

Hi @YunJ,

 

You need to have double digits on both day and month in order to get 01-01 otherwise the order will be incorrect change your format from M/D to MM/DD should do the trick


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix Thanks a lot for your solution!

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.