Forum Discussion
Hotel occupancy rates
- Anonymous10 years ago
Think I've got it solved for you:
Add an index column to your Bookings table, since I'm assuming the GuestID refers to a specific person and that person can book multiple rooms at a time or across a given time period.
Add a Date Dimension.
Your model should look like the following:
Create the following measures:
Rooms Occupied:=CALCULATE(DISTINCTCOUNT(Bookings[Index Column]),Filter(Bookings,[Date_from]<=LASTDATE(DimDate[Date])&&[Date_to]>=FIRSTDATE(DimDate[Date])))
Rooms Available (Total for Selected Dates):=CALCULATE(DISTINCTCOUNT(DimDate[Date]))*48
Total Dates Booked:=CALCULATE(DISTINCTCOUNT(DimDate[Date]),Bookings)
Total Rooms Occupied:=SUMX(Bookings,[Rooms Occupied]*[Total Dates Booked])
OccupancyRate:=DIVIDE([Total Rooms Occupied],[Rooms Available (Total for Selected Dates)])
Or
OccupancyRate:=DIVIDE([Total Rooms Occupied],[Rooms Available (Total for Selected Dates)])*DIVIDE([Rows in Bookings],[Rows in Bookings])
Pivot Table Examples:
Please mark it as a solution or give a kudo if it works for you, otherwise let me know if you run into an issue and I'll do my best to assist. Go To bipatterns.com for more techniques and user guides.
Thanks,
I don't know if sdjensen is correct. Every company has its own metrics and there may be a reason to go with the formula as originally given. But I do like the way he's thinking. So just for fun here's that version:
Oh wait, before that, things would be easier if the OccupancyTable had a unique index column. I've named it ReservationID. Also if you have room status like I described earlier, you should change the part that says ALL(RoomTable) to FILTER(ALL(RoomTable), RoomTable[Status] = "Active") or whatever fits your actual status options. OK now here's the measure:
Occupancy Rate = DIVIDE( SUMX( FILTER( OccupancyTable, OccupancyTable[Date_from] <= LASTDATE(DateTable[Date]) && OccupancyTable[Date_to] >= FIRSTDATE(DateTable[Date]) ), COUNTROWS( DATESBETWEEN(DateTable[Date], OccupancyTable[Date_from], OccupancyTable[Date_to]) ) ), (CALCULATE( DISTINCTCOUNT(RoomTable[Room_ID]), ALL(RoomTable) ) * DISTINCTCOUNT(DateTable[Date]) ) )
As usual you can always subdivide this into several measures for portability and readability. Here's a test file to play with. It just has that most recent measure in it because it's the only one I couldn't error-check in my head. :P
Vvelardeyeah I agree with that. If one room were never occupied it would never be counted using that original formula unless you had that separate table. But it sounds like that's covered in any case.
Actually I think 2 rates would be handy:
1. Rate based on total number of rooms; calculated as sum of occupied rooms per night / number of rooms per night
Day Occupied rooms Total Rooms Rate Total
1 24 48 0.50
2 12 48 0.25
Total 36 96 0.375
2. Rate based on number of available rooms calculated as sum of occupied rooms per night / number of rooms available per night
Day Occupied rooms Avail Rooms Rate Total
1 24 48 0.50
2 12 42 0.286
Total 36 90 0.4