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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
asdfasdf3321g
Regular Visitor

How can I perform a calculation based on the dates in a date slicer?

I need to create an uptime report.  I have the downtime data, which includes a device ID, date of downtime, hours of downtime, and some other fields for the technical details.

 

A simple calulation will get me the uptime percentage...

Uptime % = (Total Hours - Downtime Hours) / Total Hours

 

Where Total Hours = the total numbers of hours in a date range.  The date range is specified by a date slicer.

 

How do I get Total Hours from the slicer and into a formula for this calculation?

 

 

 

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @asdfasdf3321g ,

 

You can create measure like DAX below:

 

Total Hours=
Var MinDate = CALCULATE(MIN(CalendarDate[Date]),ALLSELECTED(CalendarDate[Date]))
Var MaxDate = CALCULATE(MAX(CalendarDate[Date]),ALLSELECTED(CalendarDate[Date]))
Return
DATEDIFF(MinDate, MaxDate, HOUR)

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi  @asdfasdf3321g ,

 

Does that make sense? If so, kindly mark my answer as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

v-xicai
Community Support
Community Support

Hi @asdfasdf3321g ,

 

You can create measure like DAX below:

 

Total Hours=
Var MinDate = CALCULATE(MIN(CalendarDate[Date]),ALLSELECTED(CalendarDate[Date]))
Var MaxDate = CALCULATE(MAX(CalendarDate[Date]),ALLSELECTED(CalendarDate[Date]))
Return
DATEDIFF(MinDate, MaxDate, HOUR)

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.