Challenge!!

Daniel Kuenstler

New Member
Joined
Apr 10, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Web
Hi,
I'm confronted with a quite challenging task, well at least for me. I already asked a lot of colleagues, but nobody was able to find the solution. Maybe someone can help me out with this here.
Here is my task: I have to calculate the real occupancy (in %) for tourist accommodation. The database I have provides check-in and a check out date. So I can easily calculate how many days/nights each booking has stayed. Further, I created a column where I assigned to each month, the number of days in that month. (30, 31 or 28 in February). Now to calculate the days the establishment was occupied, I just need to divide the sum of days booked in that month (getting them from each booking) by the days in that specific month. Let´s say: 10 nights sold in March....10/31=0,32 or 32%. Easy right? Now my assignment is to calculate the "real " occupancy. That means only the days in that month!!! In other words: if the booking of 10 nights starts on the 25th of march, then we should only calculate 5 days for March and the other 5 days should "pass over" to April. But how can I do this? How can I say to Exel (or Power BI, because I tried it as well with DAX) to count only the days that will fall into this month AND keep the "rest" of the stay for the next month? I´m stuck with this problem for several weeks now and hope that someone might pick up that challenge. (I don´t mind if you provide a solution with DAX or for Exel since I´ve tried to take the project as well to Power BI). I leave you with a link to a sample file. Feel free to experiment and thank you in advance for any help provided. sample file here!!!!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
This will be all about how you have the workbook setup. Think id create a matrix of days of the year down column A then the property names along Row 1. This can then be populated by another sheet which shows bookings and dates. Then the matrix in turn can populate a monthly sheet/s for each property. There will be a lot of ways to get this done that said.
 
Upvote 0
Hi Steve, thank you for your reply!! Not sure if I understand well what you mean exactly with creating the new matrix....probably the easy part is to calculate the days in the same month...But how can I get the remaining days to the next month? Feel free to add any changes or notes to the sample!!!! Appreciate your help!
 
Upvote 0
if the booking of 10 nights starts on the 25th of march, then we should only calculate 5 days for March and the other 5 days should "pass over" to April.
Are you excluding weekends then? I would say that it should be 7 days in March (25,26,27,28,29,30,31) and 3 in April :unsure:

The solution also depends how you want the results to be shown, as some scenarios can return misleading results if handled incorrectly. Take a longer date range, for example: 16th April to 16th June. Should the result be 200%? (50% of April +100% of May + 50% of June)?

This formula, array confirmed in L2 gives results, but they may or may not be correct.

=SUM(IFERROR(FREQUENCY(ROW(INDIRECT(E2&":"&(F2-1))),EOMONTH(ROW(INDIRECT(E2&":"&(F2-1))),0))/DAY(EOMONTH(ROW(INDIRECT(E2&":"&(F2-1))),0)),0))
 
Upvote 0
Take these two dates:

28/02/2020
05/03/2020

One in A1, other in B1. To calculate the number of days inclusive is simply:

=B1-A1+1

But provided you dont have stays that could last over a month then for February days its:

=EOMONTH(A1,0)-A1+1

and March

=B1-MAX(EOMONTH(B1,-1)+1,A1)+1
 
Upvote 0
Maybe something like below to create helper columns that split the month (assuming only two). Then the month count would be sum for the month of both columns.
I have had to switch the date format for it to function here.
Book1
DEFGHIJKLMNOPQ
1listing/titlecheck incheck outnightsnº monthyearMonth namedays in monthNightsMonthNightsMonth
209 Tomas Miller I 4A23/01/201727/01/2017412017Enero31410 
309 Tomas Miller I 4A01/01/201709/01/2017812017Enero31810 
409 Tomas Miller I 4A10/01/201717/01/2017712017Enero31710 
509 Tomas Miller I 4A18/01/201723/01/2017512017Enero31510 
609 Tomas Miller I 4A28/01/201704/02/2017712017Enero313142
710 Tomas Miller II 2A03/01/201712/01/2017912017Enero31910 
810 Tomas Miller II 2B14/01/201718/01/2017412017Enero31410 
910 Tomas Miller II 2B26/01/201730/01/2017412017Enero31410 
1010 Tomas Miller II 2B30/01/201706/02/2017712017Enero311162
1110 Tomas Miller II 2B18/01/201725/01/2017712017Enero31710 
1214 Sonneland I02/01/201709/01/2017712017Enero31710 
1314 Sonneland I11/01/201701/02/20172112017Enero3120112
1416 Farray II04/01/201730/01/20172612017Enero312610 
1517 Arinaga Playa I07/01/201714/01/2017712017Enero31710 
1617 Arinaga Playa I16/01/201728/01/20171212017Enero311210 
1717 Arinaga Playa I28/01/201730/01/2017212017Enero31210 
1818 Pizarro I Leon02/01/201712/01/20171012017Enero311010 
1918 Pizarro I Leon21/01/201704/02/20171412017Enero3110142
Sheet9
Cell Formulas
RangeFormula
N2:N19N2=MIN(EOMONTH(E2,0)-E2,F2-E2)
O2:O19O2=MONTH(E2)
P2:P19P2=MAX(F2-EOMONTH(E2,0),0)
Q2:Q19Q2=IF(P2>0,MONTH(F2),"")
F2:F19F2=E2+G2


Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top