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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MalcolmLeong
Frequent Visitor

How to build measure for % occupancy for hotel

Here's a sample of what I am looking at:

1. I have several hotels.  In this case, Hotel A and Hotel B.

2. In each hotel, I have (i) a daily breakdown, and (ii) the segment breakdown contributing to the sales

3. I have a fixed room inventory for each hotel : hotel A (300 rooms a day) and hotel B (100 rooms a day)

 

Problem :

1. I need to build a robust measure for occupancy, which is (Room Nights / Inventory). 

2. The measure will stand whether I remove the segment and/or remove the dates

 

Here's how it will look like.  I am trying to calculate the green colum Occupancy %.

1. The measure can be broken down by day/by segment/by hotel, etc

2. But I should also be able to aggregate it for e.g. if I removed the segment, Hotel A will be 77% on 1 Dec (i.e. (80+100+50)/300)), or even if I remove the dates, Hotel A will be 71% on 1Dec and 2Dec aggregated (i.e. (80+100+50+50+120+30) / (300+300).

 

 

 Sample data.png

 

Here is how my data table actually looks like and I'm having difficulties in building the measure that I need:

 

Data table.png

 

Any help will be much appreciated!

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@MalcolmLeong,

In your table, create the following measure.

Occupancy% = SUM(Table[Room Nights])/MAX(Table[Inventory])

1.JPG2.JPG

For your last requirement that "even if I remove the dates, Hotel A will be 71% on 1Dec and 2Dec aggregated (i.e. (80+100+50+50+120+30) / (300+300)", please firstly create new table using DAX below.

NewTable = SUMMARIZE(Table,Table[Hotel],Table[Date],"room nights",SUM(Table[Room Nights]),"inventory",MAX(Table[Inventory]))


Then create the following measure in the new table.

percentage = DIVIDE(SUM('NewTable'[room nights]),CALCULATE(SUM('NewTable'[inventory]),FILTER('NewTable','NewTable'[Date]<=MAX('NewTable'[Date]))))

3.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

1 REPLY 1
v-yuezhe-msft
Employee
Employee

@MalcolmLeong,

In your table, create the following measure.

Occupancy% = SUM(Table[Room Nights])/MAX(Table[Inventory])

1.JPG2.JPG

For your last requirement that "even if I remove the dates, Hotel A will be 71% on 1Dec and 2Dec aggregated (i.e. (80+100+50+50+120+30) / (300+300)", please firstly create new table using DAX below.

NewTable = SUMMARIZE(Table,Table[Hotel],Table[Date],"room nights",SUM(Table[Room Nights]),"inventory",MAX(Table[Inventory]))


Then create the following measure in the new table.

percentage = DIVIDE(SUM('NewTable'[room nights]),CALCULATE(SUM('NewTable'[inventory]),FILTER('NewTable','NewTable'[Date]<=MAX('NewTable'[Date]))))

3.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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