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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
TwinkleMittal
Frequent Visitor

Percentage of rooms checked out in a month that were booked in previous months

Hi, 

 

I have hotel data : Reservation Date, CheckOut Date, Room, etc. 

 

Suppose 500 rooms were booked/reserved in a month (Jan), out of which 60 were checked out in the same month(Jan), 50 in next month (feb), 40 in march and so on. 

TwinkleMittal_0-1647734733957.png

I want to get the %  of rooms checked out in jan, feb, march, etc that were booked in Jan itself using DAX expressions. 

TwinkleMittal_1-1647734891955.png

Can anyone please help me? 

 

 

1 ACCEPTED SOLUTION

Hi @TwinkleMittal ,

 

Here's my solution.

 

1.Create a Month column.

Month = FORMAT([CheckOutDate],"MMM")

vstephenmsft_0-1647928134864.png

 

2.Create a measure.

Percentage = 
VAR _TOTAL =
    CALCULATE ( SUM ( 'Table'[RoomNights] ), ALL ( 'Table' ) )
VAR _SUB =
    CALCULATE ( SUM ( 'Table'[RoomNights] ), ALLEXCEPT ( 'Table', 'Table'[Month] ) )
RETURN
    DIVIDE ( _SUB, _TOTAL )

vstephenmsft_1-1647928184101.png

 

You can check more details from my attachment.

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Fowmy
Super User
Super User

@TwinkleMittal 

Can you share some sample data with the desired output to have a clear understanding of your question?
Mention whether you want a calculated column or measure.
You can either paste your data in the reply box or save it in OneDrive, Google Drive, or any other cloud-sharing platform and share the link here.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy 

 

Below is the sample data. 

 

ResDateCheckOutDateRoomNights
01-03-22 10-04-22 4
01-03-22 20-04-22 3
01-03-22 06-05-22 2
01-03-22 10-05-22 1
01-03-22 23-05-22 1
01-03-22 19-06-22 2

 

As you can see in the table above, the bookings (ResDate) were made in march but is going to be checked out (CheckOut Date) in April, may and june. I want to see the percentage distribution of all the bookings made in march over the future months. 

 

In this case, 13 bookings were made in March 2022, out of which 53.8% (3+4 = 7) is going to be checked out in April,  30.76% in may and 15.38% in June. I want to get this percentage value. It can be a measure or a column. 

 

Thanks, 

Twinkle 

Hi @TwinkleMittal ,

 

Here's my solution.

 

1.Create a Month column.

Month = FORMAT([CheckOutDate],"MMM")

vstephenmsft_0-1647928134864.png

 

2.Create a measure.

Percentage = 
VAR _TOTAL =
    CALCULATE ( SUM ( 'Table'[RoomNights] ), ALL ( 'Table' ) )
VAR _SUB =
    CALCULATE ( SUM ( 'Table'[RoomNights] ), ALLEXCEPT ( 'Table', 'Table'[Month] ) )
RETURN
    DIVIDE ( _SUB, _TOTAL )

vstephenmsft_1-1647928184101.png

 

You can check more details from my attachment.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.