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

Hello Need help with week sorting

Hello, I have created below column and when I am adding it to slicer it is not giving me correct sorting order. how can I fix it?

WeekEnding =
VAR myWeekNum = WEEKNUM([Date])
VAR myYear = YEAR([Date])
VAR myEndDate = CALCULATE(MAX([Date]),FILTER(ALL(DateSlicer),YEAR([Date])=myYear && DateSlicer[WeekNum]=myWeekNum && DateSlicer[WeekDay]=6))
VAR myEndDate1 = IF(NOT(ISBLANK(myEndDate)),myEndDate,CALCULATE(MAX([Date]),FILTER(ALL(DateSlicer),YEAR([Date])=myYear+1 && DateSlicer[WeekNum]=1 && DateSlicer[WeekDay]=6)))
VAR myEndDate2 = IF(NOT(ISBLANK(myEndDate1)),myEndDate1,MAX([Date]))
RETURN " Friday " & myEndDate2

 

 

1 ACCEPTED SOLUTION

Press on your column where you have put the values for the slicer , you will find in column tools above something called sort column by , pressit and choose by weeksort column this should fix it

View solution in original post

5 REPLIES 5
eliasayyy
Super User
Super User

To sort weeks create a week id

 

Weekid =

VAR  _y = Year(min('table'[Date]))

RETURN

WEEKNUM('table'[Date],2) + (YEAR('table'[Date]) - _min) *53

 

I am using slicer and I am using weekending column from above post. how would your column help me to sort weekending column?

Can you please show me a sample of th results?

your soultion works fine. but what I want is I am trying to add different column on slicer and how can I sort it

davehardikkumar_0-1683658138390.png

in above screenshot, weeksortid is your calculation which is working fine but and I want to sort it by Weekendingtest column in slicer. how can I achieve that?

Press on your column where you have put the values for the slicer , you will find in column tools above something called sort column by , pressit and choose by weeksort column this should fix it

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.