Forum Discussion
Daily Occupancy Average
Hi everybody,
I have a table that shows the Start Date, End Date and Customer ID. What I want to do is to see the daily occupancy average per period of time (year for example and be able to drill down to a month). Another requirement is the ability to see on each day how many occupants there were exactly (not sure if that would be on a different visual).
For example:
for 11/07/2018- I would have everybody that started on this date minus people that left on this day plus people that have arrived earlier but either checked out later or haven't checked out yet (end date = blank).
This is pretty much a sample of what I have where num is the customer ID. Like I mentioned before the blank end date should be considered as not ended yet.
Can somebody please help me out? Thank you so much in advance!
| num | start date | end date |
| 700 | 12/17/2015 | 8/11/2016 8:18 |
| 1096 | 12/31/2015 | 12/31/2015 21:27 |
| 1095 | 12/30/2015 | 12/30/2015 16:59 |
| 920 | 12/15/2015 | 12/15/2015 15:31 |
| 1080 | 12/14/2015 | 12/14/2015 4:39 |
| 1077 | 12/9/2015 | 12/9/2015 13:21 |
| 1078 | 12/9/2015 | 12/9/2015 2:52 |
| 904 | 8/26/2015 | 8/26/2015 12:01 |
| 897 | 12/6/2015 | 12/6/2015 4:44 |
| 1074 | 12/2/2015 | 12/2/2015 3:08 |
19 Replies
- v-frfei-msftCommunity Support
Hi mpmsltd ,
Please check the following steps as below:
1. Create the inactive relationship between tables as below.
2. Then we can create measures as below to work it out.
Measure = VAR mind = MIN ( 'date'[Date] ) VAR mad = MAX ( 'date'[Date] ) VAR a = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table' ), mind >= 'Table'[start date] && OR ( 'Table'[end date] >= mad, 'Table'[end date] = BLANK () ) ) ) RETURN aMeasure 2 = VAR d = MAX ( 'date'[Date] ) VAR a = CALCULATE ( COUNTROWS ( 'Table' ), USERELATIONSHIP ( 'date'[Date], 'Table'[start date] ) ) VAR b = CALCULATE ( COUNTROWS ( 'Table' ), USERELATIONSHIP ( 'date'[Date], 'Table'[end date] ) ) VAR c = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[start date] > d && OR ( 'Table'[end date] = BLANK (), 'Table'[end date] > d ) ) ) RETURN a - b + cFor more details, please check the pbix as attached.
- mpmsltdHelper I
Hi v-frfei-msft thank you so much for your help.
But the totals are off, please check the file attached. For example the total for January 2017 is showing 586 but then all the days have more than 700 people. Can you please check it again? Also how can I attach my pbix file in here?
THanks!
- Ashish_MathurSuper User
- mpmsltdHelper I
Thanks Ashish_Mathur but this is not what I need.
What I need is the daily occupancy average - which is a calculation of: customers that were staying on that day + customers that arrived on that day - customers that left on that day
- Ashish_MathurSuper User
Hi,
You are welcome. Show me your exact expected result.
- AnonymousNot applicable
Hello All,
Thanks for your replies. Ashish_Mathur ´s solution has helped us a lot.
Now, we want to take it to the next level and evaluate this measure for a MONTH scale or even within a YEARLY basis.
This is not being possible since the total OCCUPIED ROOMS are not a sum of the occupied rooms for every night. I believe this was also the case for posted solution, since the total does not match up with the correct sum for the period of nights shown.
Any ideas how we can manage this?
In case you need to see toher tables from our model, let me know.
Thanks in advance!!
Santiago Sanchez
P.S: In our model, every reservation code has a defined number of occupied rooms (the values are calculated also using a TABLE created within POWERQUERY ).
- Ashish_MathurSuper User
Hi,
Share the link from where i can download your PBI file and show the expected result.
- AnonymousNot applicable
First of all, thank you all for helping us.
THis is the link where you can download the pbix. file:
https://1drv.ms/u/s!AtEu70FghQZohcZeLVDKCRAsVeh3Xg?e=WbXSad
Now, there you will see my comments and the expected results there.
We are having trouble since the total values for the measure is not computing the sum of rooms occupied per night. So no clue on getting a monthly avarage occupancy rate...
Thanks so much.
Santiago Sanchez