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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
GabrielSantos
Resolver I
Resolver I

Relative Date Filter with Explicit Date Range Option

I would like to accomplish the following:

 

1. The report defaults to YTD (in an ideal world, you would also be able to have a dropdown to select common business dates such as Same Period Last Month, YTD, MTD, etc.)

2. The user has the ability to manually enter any explicit date range, such as 1/1/2018 - 1/3/2019, 2/1/2019 - 3/5/2019, etc.

3. The explicit date range selection will carry over to other pages of the report.

 

Here's what I've tried:

1. Relative date filtering. This doesn't work becuase there is no way to explicitly enter a date range. It is impossible to select 2/1/2019 - 3/5/2019 because the relative date filtering is always relative to today.

 

 

1 REPLY 1
Stachu
Community Champion
Community Champion

Ad. 1) create a table 'Periods' like this:

Period
MTD
YTD
LY
YTD LY

and a measure like this:

Measure = 
VAR __Period = SELECTEDVALUE(Periods[Period])
VAR __MTD = DATESMTD('Calendar'[Date])
VAR __YTD = DATESYTD('Calendar'[Date])
VAR __YTD_LY = SAMEPERIODLASTYEAR(__YTD)
VAR __LY = SAMEPERIODLASTYEAR('Calendar'[Date])
RETURN
SWITCH(
__Period, "MTD", CALCULATE([SumOfValue],__MTD), "YTD", CALCULATE([SumOfValue],__YTD), "YTD LY", CALCULATE([SumOfValue], __YTD_LY), "LY", CALCULATE([SumOfValue], __LY), BLANK() )

adjust the table and measure names accordingly

it will always calculate the values depending on the filter context in the calendar table, see here:

Capture.PNG

Ad.2 just create a regular slicer based on your Calendar table - it will provide the reference point for all the MTD/YTD calculations, i.e. if you select 201907 in this slicer the visual above would only return single row.

With multiple months selected (e.g. 201905-201907) the MTD/YTD/LY calculations get a bit counterintuitive, so I would really think on what you want to present and how

Ad.3 you have to use synced slicers

 

https://docs.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-slicers#sync-and-use-slicer...

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors