The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi
I have a requirement like by default in slicer it should select current week and previous week in the slicer can any one please help me out with this requirement.
Thanks
Solved! Go to Solution.
HI @shilpa123,
The current slicer does not support setting default values, you can create a calculated column to check row values based on current DateTime and return flags.
After these steps, you can manually select the flags and save them to bookmark, then you can bind this bookmark to the button action and use it to reset the default selection. (notice: this calculate column will be dynamic change based on current system DateTime)
Create report bookmarks in Power BI to share insights and build stories - Power BI | Microsoft Docs
Regards,
Xiaoxin Sheng
To set a default selection in a Power BI slicer to current week and previous week, you'll need to use a combination of calculated columns, DAX measures, and potentially a custom table to drive slicer behavior. Unfortunately, Power BI slicers do not support default selections natively without user interaction, but you can work around this by creating a calculated column or flag for filtering visuals or syncing slicers.
Here's a step-by-step approach:
Step 1: Create a Date Table (if not already available)
Make sure you have a proper Date table with continuous dates.
DateTable =
ADDCOLUMNS (
CALENDAR (DATE(2022,1,1), DATE(2030,12,31)), -- Adjust range as needed
"Year", YEAR([Date]),
"Week Number", WEEKNUM([Date], 2), -- 2 = week starts on Monday
"Year-Week", YEAR([Date]) * 100 + WEEKNUM([Date], 2)
)
Step 2: Add a Flag Column for Current and Previous Week
WeekFlag =
VAR CurrentYear = YEAR(TODAY())
VAR CurrentWeek = WEEKNUM(TODAY(), 2)
VAR DateYear = YEAR('DateTable'[Date])
VAR DateWeek = WEEKNUM('DateTable'[Date], 2)
RETURN
IF (
(DateYear = CurrentYear && DateWeek = CurrentWeek) ||
(DateYear = CurrentYear && DateWeek = CurrentWeek - 1),
"Current/Previous Week",
"Other"
)
Step 3: Use the Flag in a Slicer
Add the WeekFlag column as a slicer.
Set it to single-select OFF and multi-select ON.
Use bookmarks to pre-select the slicer state (optional workaround).
Optional Visual Filter Approach (Without Slicer Selection)
If the slicer is just to filter visuals, you can use a visual-level filter or DAX measure like:
IsCurrentOrPreviousWeek =
VAR CurrentYearWeek = YEAR(TODAY()) * 100 + WEEKNUM(TODAY(), 2)
VAR PrevYearWeek = CurrentYearWeek - 1
RETURN
IF (
'DateTable'[Year-Week] = CurrentYearWeek ||
'DateTable'[Year-Week] = PrevYearWeek,
1, 0
)
Then apply this as a visual-level filter where IsCurrentOrPreviousWeek = 1.
What are the best ways to mitigate implementation risks?
The best way to mitigate implementation risks is to use phased rollouts, engage a certified Microsoft partner like Havi Technology, invest in comprehensive user training, follow a structured data migration plan, and maintain strong change management.
HI @shilpa123,
The current slicer does not support setting default values, you can create a calculated column to check row values based on current DateTime and return flags.
After these steps, you can manually select the flags and save them to bookmark, then you can bind this bookmark to the button action and use it to reset the default selection. (notice: this calculate column will be dynamic change based on current system DateTime)
Create report bookmarks in Power BI to share insights and build stories - Power BI | Microsoft Docs
Regards,
Xiaoxin Sheng
Hi, If you have any requirement like by default in slicer. you can contact Dynamics Square. Dynamics Square is a Microsoft Partner. You can contact directly