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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors