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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ShamR9T
Frequent Visitor

Calculate Monthly Occupancy based on Checkin Checkout dates

I have a problem I want to solve. I have a main table which is the reservations and has details of the guest. it has details like nationality, checkin date, biographical date etc. this also means that there are multiple guests that can checkin and checkout on the same date. here is some sample data. I want to create a dynamic measure by connecting this to a dates table where you can calculate the daily occupancy rate based on their checkin and checkout date and then be able to calculate the total room revenue for the day and which nationality they are from.

 

I can do it for daily using a simple measure where the the date from date table is greater than checkin date and smaller than checkout. but I cant aggregate it to a monthly or quarterly basis where I want to calculate all the nights the room was occupied in that month.

 

For an example someone who checks in on 30th December and checks out on 2nd January has 2 nights (30th and 31st December) in December and 1 night (January 1st) in January. I hope my question is clear and you guys are able to help.

 

Thanks in Advance

 

here is a sample dataset

 

CheckinCheckoutDurationNationalityRoom RateProperty
12/1/202212/11/202210.00British120Italian
1/1/20232/15/202345.00American220Italian
12/28/20221/21/202324.00British145Ibiza
5/1/20235/11/202310.00British320Ibiza
9/11/202210/1/202220.00Australian111Ibiza
5/1/20235/9/20238.00American220Italian
5/1/20235/21/202320.00Australian111Ibiza

 

This is the outcome I am hoping to achieve (PS. I havent done the calculations thoroughly so might be some errors but I hope you understand) and I want this to be filtered by nationality or property etc. 

 

MonthYearRoom Nights
December202244
January202360
February202315
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1673191759485.png

 

Jihwan_Kim_0-1673191727317.png

 

 

Room nights measure: =
VAR _newtable =
    GENERATE (
        Data,
        FILTER (
            DISTINCT ( 'Calendar'[Date] ),
            'Calendar'[Date] >= Data[Checkin]
                && 'Calendar'[Date] <= Data[Checkout]
        )
    )
RETURN
    COUNTROWS ( _newtable )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Sorry. Just to also add. I dont think this solution is accounting for guests that checked in prior to the beginning of the period either. so for example someone who checked in on December 31st and checked out on February 2nd isnt accounted for in January. 

Thats actually a very interesting solution. Thank you so much. yes. it has definitely helped with the problem of getting the data on monthly basis. And I think you understood my predicament quite well. 

Just One more question. If I am to replicate this for quarterly figures, or any other period, should I add a new column specifying the quarter and then continue like that as well?

 

I did try this solution as well from a different post. But cant seem to replicate the same logic here. DAT being the main data table and Sheet 2 being the date table. But it keeps outputting blank values. 

 

ShamR9T_1-1673200749244.png


Thanks for your help.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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