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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
asdfasdf3321g
Regular Visitor

Is it possible to get the date range in a date slicer?

I need to generate a downtime report for devices.  I have a database of support tickets.  If a device is down, I have a ticket which includes the date of the problem and the number of hours of downtime.

 

The calculation would look something like this...

Sum of Downtime / DATEDIFF(MinDate, MaxDate, HOUR) = downtime percentage

 

I posted this question a while back and got this answer...

https://community.powerbi.com/t5/Desktop/How-can-I-perform-a-calculation-based-on-the-dates-in-a-dat...

 

The problem with this solution is that it looks at the records filtered by the date slicer, rather than the date slicer itself.  If I select January 1 - January 31 in the slicer, the earliest ticket might be January 10 and the latest ticket might be January 20, then the datediff is calculated based on the ticket dates rather than the date selected in the slicer.

 

Is there a way to get the values selected in the slicer?

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

If you have a Calendar table that is what your slicer is based on, then you should be able to do this:

Diff =
VAR __Max = MAX('Calendar'[Date])
VAR __Min = MIN('Calendar'[Date])
...


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
MFelix
Super User
Super User

Hi @asdfasdf3321g ,

 

Use the following code:

 

Measure = DATEDIFF(min(Table[Date]);MAX(Table[Date]);HOUR)

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



amitchandak
Super User
Super User

@asdfasdf3321g , Can you share sample data and sample output?

 

You can refer my blog for date diff: https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Differ...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

Also, VALUES('Calendar'[Date]) should get you all of the values in a single column table.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

If you have a Calendar table that is what your slicer is based on, then you should be able to do this:

Diff =
VAR __Max = MAX('Calendar'[Date])
VAR __Min = MIN('Calendar'[Date])
...


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I had to look up a "calendar table" but that worked, thanks for pointing me in the right direction.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors