upwardD
December 22, 2021, 2:12pm
1
Hi,
Trying to sort Day-Month column and it is strange that it is not working out to be quite easy like Month-Year.
I have tried googling for this solution and none is working for me. I do need your help.
PBI file attached.
Day_Month_Sort.pbix (319.2 KB)
Thank you
Melissa
December 22, 2021, 2:38pm
2
Hi @upwardD ,
The granularity doesn’t match between the Date[Day & Month] and Date[DayMonthSort] columns.
A Sort By column needs to be an equivalent of that what needs to be sorted so Date[Day & Month] would translate to:
FORMAT( CONVERT( 'Date'[WeeK Commencing], DATETIME ), "ddmm" )
Here’s your sample file.
Day_Month_Sort.pbix (320.2 KB)
I hope this is helpful
1 Like
upwardD
December 22, 2021, 2:43pm
3
Thank you @Melissa for the reply.
I got an error while using the code above:
Thank you
Melissa
December 22, 2021, 2:47pm
4
Attached the sample in my previous response.
I hope that helps
1 Like
upwardD
December 22, 2021, 2:54pm
5
I am very grateful!
Thank you @Melissa
upwardD
December 23, 2021, 2:37am
7
Hi @Melissa , I am sorry I’m coming back to this again. I noticed some discrepancies in the sort order. Please see the image attached and the highlighted bars.
I look forward to your reply
Grateful!
Melissa
December 23, 2021, 7:24am
8
Right, give this a go…
DayMonthSort =
VAR d = SUBSTITUTE( 'Date'[Week Commencing], "/", "|")
VAR n = PATHITEM( d, 2, INTEGER )*100 + PATHITEM( d, 1, INTEGER )
RETURN n
Set column type to: Whole number
I hope this is helpful
3 Likes
upwardD
December 23, 2021, 8:15am
9
Thank you @Melissa , it works perfectly!!
Grateful
1 Like