Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
My report has data going back to 2023-07-01. I am hoping I can adjust the slicer to default to showing the last 30 days worth of data, including yesterday, but not today. I am hoping the slicer has this defaulted when the user views the report and the user does not have to adjust the slicer to the most recent data.
In the image of the slicer above, the user can slide to get earlier data, but has to move the right slicer to get the most recent data. I want to avoid that.
I do not want to filter the visual because there is historical data I want the user to be able to see, I just want the default view to be the last 30 days.
Is this at all possible?
One idea is to use a Calculation Group with a Calculation Item that applies the default Date filter to all measures if no filter has been applied. This would work fine as long as applying a date filter to measures results in all visuals displaying as intended.
(This is a similar idea to this article on SQLBI).
I have attached an example PBIX to illustrate the idea.
1. Create a measure Date Filter Message
Returns an empty string but will be modified by Calculation Item below.
Date Filter Message =
""
2. Create a Calculation Group called Date Filter
-----------------------------------
-- Calculation Group: 'Date Filter'
-----------------------------------
CALCULATIONGROUP 'Date Filter'[Filter Option]
CALCULATIONITEM "Default" = SELECTEDMEASURE ()
CALCULATIONITEM "Last 30 Days if no filter" =
VAR DateFormat = "d-mmm-yy"
VAR NumDays = 30
RETURN
IF (
CALCULATE ( ISFILTERED ( 'Date' ), ALLSELECTED ( ) ),
SELECTEDMEASURE ( ),
VAR TodayDate = TODAY ( )
VAR DateFilterMax = TodayDate - 1 -- start from TODAY - 1
VAR DateFilterMin = TodayDate - NumDays -- 30 days backwards
RETURN
IF (
ISSELECTEDMEASURE ( [Date Filter Message] ),
"Default date filter applied: " & UNICHAR ( 13 )
& FORMAT ( DateFilterMin, DateFormat )
& " — "
& FORMAT ( DateFilterMax, DateFormat ),
CALCULATE (
SELECTEDMEASURE ( ),
KEEPFILTERS (
DATESBETWEEN ( 'Date'[Date], DateFilterMin, DateFilterMax )
)
)
)
)
3. Apply a Report-level filter (or Page-level if needed): 'Date Filter'[Filter Option] = "Last 30 Days if no filter"
4. Then with no Date filter applied (via slicer or other means), the default filter is applied (with Date Filter Message displayed in a Card):
5. If a Date filter is applied, it then takes effect and overrides the default:
Would something like this work for you?
Regards
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
17 | |
10 | |
10 | |
8 | |
6 |
User | Count |
---|---|
20 | |
18 | |
17 | |
13 | |
10 |