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
bzafft123
Regular Visitor

Calendar Sort Start of week in Filters Pane to most recent.

My calendar table was created in Power Query(= Table.AddColumn(#"Changed Type", "DateTable", each List.Dates(#date(2019,01,01), 365*6, #duration(1,0,0,0))).

I have a slicer that shows the most recent 'Start of Week' first (see below, from a different report, using a date field on a table instead of a calendar table). I want to see if I can get this same sort on the right in the filters pane on my current report. I have tried sorting the column by another column, but it's not working. 

bzafft123_0-1685974377251.png

Here is the filter pane view. 

bzafft123_1-1685974406877.png

Is it possible to have the most recent week show first?

 

 

 

1 ACCEPTED SOLUTION

Thank you, yes, six years for forecasting purposes. I created a reference table that had a relationship to my date table. On that table, I kept columns Start of Week, Year, Name of Day, Week of Year, then filtered 'Name of Day' = 'Sunday.' Then created a column for the 'Current Week' with DAX below.

 

Current Week = VAR _Today = TODAY()

VAR _WeekToday = WEEKNUM ( _Today )

VAR _YEARToday = YEAR ( _Today )

RETURN IF ( UniqueStartofWeek[Year] = _YearToday && UniqueStartofWeek[Week of Year] <=_WeekToday  , "Y" )
 
Then I created another column on the reference table for the 'Start of Week' that was in Descending order:
 
Start of Week Descending = ((UniqueStartofWeek[Year] *100)  + UniqueStartofWeek[Week of Year] )*-1
 
Then I could add 'Start of Week' Column to the filter pane and add 'Current Week' = Y, which then filtered the filter to show the most recent week on top. 
 
The final result shows this:
bzafft123_0-1686139721513.png

 

I hope this helps someone else. 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Table.AddColumn(#"Changed Type", "DateTable", each List.Dates(#date(2019,01,01), 365*6, #duration(1,0,0,0))).

You are creating a six year calendar for each row of your table?!?

 

In DAX you can sort one column by another column.  Subtract each date from TODAY() and use that for sorting.

Thank you, yes, six years for forecasting purposes. I created a reference table that had a relationship to my date table. On that table, I kept columns Start of Week, Year, Name of Day, Week of Year, then filtered 'Name of Day' = 'Sunday.' Then created a column for the 'Current Week' with DAX below.

 

Current Week = VAR _Today = TODAY()

VAR _WeekToday = WEEKNUM ( _Today )

VAR _YEARToday = YEAR ( _Today )

RETURN IF ( UniqueStartofWeek[Year] = _YearToday && UniqueStartofWeek[Week of Year] <=_WeekToday  , "Y" )
 
Then I created another column on the reference table for the 'Start of Week' that was in Descending order:
 
Start of Week Descending = ((UniqueStartofWeek[Year] *100)  + UniqueStartofWeek[Week of Year] )*-1
 
Then I could add 'Start of Week' Column to the filter pane and add 'Current Week' = Y, which then filtered the filter to show the most recent week on top. 
 
The final result shows this:
bzafft123_0-1686139721513.png

 

I hope this helps someone else. 

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.