cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seanguerrero
Frequent Visitor

DAX to Calculate Room Utilization by Hour and Day

Hi PBI Community,

 

I'm trying to calculate hourly % utilization with a sample of the following data points. I want to display a matrix visual that shows by day and hour, the percentage of rooms occupied (similar to the last image). I found this DAX on this site but couldn't get it to calculate correctly. I also need to ensure that the appropriate utilization is calculated for the hours inbetween "In" and "Out." For instance, if 'In' is 8am and 'Out' is 10am, I need to make sure that the DAX accounts for the 9am hour. 

 

Sorry -- new to DAX and looking to learn from the community.

_______________________

 

Measure Utilization =

 

var _occupied =
CALCULATE(COUNT('Source'[Guest]),
FILTER(ALLSELECTED('Source'),
'Source'[In]<=MAX('Table Time'[Time])&&'Source'[Out]>=MAX('Table Time'[Time])&&'Source'[Date]=MAX('Table Calendar'[Date])))

 

var _utilization =

DIVIDE(_occupied,20) // for 20 rooms

 

return
IF(_utilization = BLANK(),0,_utilization)

 

 

seanguerrero_0-1628791000383.png

 

seanguerrero_1-1628791010112.png

 

seanguerrero_2-1628791564166.png

 

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@seanguerrero , change var _occupied  like this and try

 


var _occupied =
Sumx( addcolumns( summarize( 'Source', 'Source'[Guest], source[Date] ) , "_1", calculate(COUNT('Source'[Guest]),
FILTER(ALLSELECTED('Source'),
'Source'[In]<=MAX('Table Time'[Time])&&'Source'[Out]>=MAX('Table Time'[Time])&&'Source'[Date]=MAX('Table Calendar'[Date])))), [_1])

Thanks for the reply @amitchandak. I changed var _occupied per your recommendation. After charting Source[Date] and Table Time[Time], I'm getting zeros. Any help would be greatly appreciated! Thanks again!

 

 

seanguerrero_0-1628865295804.png

 

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors