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
Kalaivani
Helper II
Helper II

Need to set default value for between date slicer along with the access to select any dates.

Hi All,

 

I have a simple question on a date slicer but am unable to find a fix for it. 

 

I have a between date slicer. I want the slicer to be by default selected to last 12 weeks(Last 12 weeks based on the field WeekBeginDate that I used for the calendar).

 

At the same time, user should be able to switch to any weeks that are before 12 weeks.

 

As far I checked, there is no proper soution for this fix. 

 

Can anyone please help me on this? I would be really a great help for me.

 

And am not able to attacg the power bi file here? Will anyone help me on houw to upload the file here?

 

Thanks so much in advance!!

 

@powerbi2 @PowerBI @powerbi3 

2 REPLIES 2
Kalaivani
Helper II
Helper II

Hi @System0verride  Thanks for the reply. The solution which you provided working in a way like the slicer is also defaulting to only the last 12 weeks. I am not able to select any weeks before 12 weeks. But I want tos select previous weeks also in the same slicer.  And I don't want to show filter in the report with any flag that the user can edit because of my requirement restrictions.

System0verride
New Member

I would first create a week number calculated column by using the WEEKNUM function in DAX: 

WeekNumber = WEEKNUM('Date'[Date], 2)

then I would calculate the most recent week begin day using your WeekBeginDate column and the MAX() function: 

MostRecentWeekBeginDate = MAX('Date'[WeekBeginDate])

 After that I would figure out the beginning of the last 12 weeks date range using the MostRecentWeekBeginDate Column: 

StartOfLast12Weeks = 
VAR MostRecentWeek = [MostRecentWeekBeginDate]
RETURN
MostRecentWeek - 84

 And finally I would filter WeekBeginDate (the column in the slicer field) by this measure: 

WeekBeginDate Filter =
VAR MostRecentWeek = [MostRecentWeekBeginDate]
VAR StartOf12Weeks = MostRecentWeek - 84
RETURN
'Date'[WeekBeginDate] >= StartOf12Weeks && 'Date'[WeekBeginDate] <= MostRecentWeek

Make sure the filter is set by default but the user can edit it.

Hope this helps!

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.

Top Kudoed Authors