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
imocean
Frequent Visitor

How to retrieve the selected date range from relative date filter or date slicer

Hello everyone, my first question here hopefully a very basic one for many! 

I have a date filter in my report (in the relative mode so it's like 'last 3 months' etc.). Is there a way to retreive what's been selected in the filter in a measure so I can use it to do some calculations such as sales target etc.? I tried the formula below but it doesn't take the filter at all, instead it just gives me the total number of months in Date table regardless. 

 

SelectedNumberMonths = DATEDIFF(CALCULATE(MIN('Date'[Date]),ALLSELECTED('Date'[Date])), calculate(MAX('Date'[Date]),ALLSELECTED('Date'[Date])), Month)

 

And Date table is a table created to read calendar between 1/01/2001 and 31/12/2025. 

 

CALENDAR (DATE(2001,1,1), DATE(2025,12,31)
 
Thanks! 
1 REPLY 1
imocean
Frequent Visitor

Sorry for this but looks like working now after I added the slicer another time (rather than using the existing one - a bit weird). I will test further to make sure it's fully working though. Thanks anyway. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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