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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
tmhalila
Resolver II
Resolver II

Dynamic Slicer to select previous week as default

Hello team,

I need your help I have a dataset that tracks daily events with report date and that date is in relationship with the dim_date attached to this post. I want to add a column in the dim_date that I can use in the slicer to select the previous week as the default with the assumption that the week starts on Monday as per the last column of the dim_date.

 

sample dataset 

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

That is possible but only if your Calendar table is sourced in Import Mode and is refreshed at least weekly.

 

Here's the standard pattern (adjust to your needs):

- create a string representation of your date column, replace the latest date with a string "Latest"
- sort that new column by the original date column
- add a slicer or visual/page/report level filter
- set the filter to "Latest"
- publish the pbix to the workspace/app

View solution in original post

I tried to add this mesure it worked fine!

 

cx_last_week = 
VAR max_date = MAX(dim_date[cx_end_of_week])
RETURN 
 If(dim_date[cx_end_of_week] = max_date -7, "Last week", dim_date[weekly_start_monday_day_dates])

 Thanks for your time  

View solution in original post

4 REPLIES 4
Nayan_surya
Helper I
Helper I

Hi @tmhalila ,

 

My client also had this requirement that he needed to last week by default without any bookmark. What we ended up doing was buying a custom visual named Date Picker by Powerviz. It had this feature of default selection built in so made the job easy and the client happy.

 

Nayan_surya_0-1702627781053.png

 

if you can see in the above example the max week is selected by default.

 

I think you should check them out.

Here is a link if you want to check this visual - https://appsource.microsoft.com/en-us/product/powerbivisuals/truvizinc1674781244292.date-picker-by-p...  (I believe they offer a free version too)

 

lbendlin
Super User
Super User

That is possible but only if your Calendar table is sourced in Import Mode and is refreshed at least weekly.

 

Here's the standard pattern (adjust to your needs):

- create a string representation of your date column, replace the latest date with a string "Latest"
- sort that new column by the original date column
- add a slicer or visual/page/report level filter
- set the filter to "Latest"
- publish the pbix to the workspace/app

Thanks for your idea,

I have updated the changes with data related to my dataset and from the idea you provided I can get the current week but I want the last week before the current week. I have tried some formulas with errors.

tmhalila_0-1700391808060.png

 

Attached is the Power BI project.

 

Sample Project  

I tried to add this mesure it worked fine!

 

cx_last_week = 
VAR max_date = MAX(dim_date[cx_end_of_week])
RETURN 
 If(dim_date[cx_end_of_week] = max_date -7, "Last week", dim_date[weekly_start_monday_day_dates])

 Thanks for your time  

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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