Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I have two tables: the example below and a generic date table.
| Guest ID | Bed ID | Check-In Date | Checkout Date |
| 1 | 100 | 01/01/2026 | 01/08/2026 |
| 2 | 102 | 01/01/2026 | 01/05/2026 |
| 3 | 104 | 12/31/2025 | 01/10/2026 |
| 4 | 106 | 01/02/2026 | 01/03/2026 |
If I wanted to create a table to show the occupancy per night, how could I go about that with just the date range of check in and check out? Some stays are months long, so any method that pulls all the middle dates out into a column or row wouldn't necessarily be ideal
Output wanted:
| Date | Guests |
| 12-31 | 1 |
| 01-01 | 3 |
| 01-02 | 4 |
| 01-03 | 3 |
Solved! Go to Solution.
Hello @ihatethis
Daily Occupancy =
VAR SelectedDate = MAX('Date'[Date])
RETURN
CALCULATE(
COUNTROWS('GuestTable'),
FILTER(
'GuestTable',
'GuestTable'[Check-In Date] <= SelectedDate &&
'GuestTable'[Checkout Date] > SelectedDate
)
)
If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.
Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn
This is a classic occupancy / hotel nights problem and it’s 100% solvable with DAX, without exploding dates into rows.
You already have:
Fact table: Stays (Guest ID, Check-In Date, Checkout Date)
Date table: Calendar[Date]
Create ONE relationship only:
Calendar[Date] → Stays[Check-In Date] (active)
(Checkout date will be handled in DAX, not relationships)
Create this measure:
Guests Occupied =
VAR CurrentDate =
SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
CALCULATE (
DISTINCTCOUNT ( Stays[Guest ID] ),
FILTER (
ALL ( Stays ),
Stays[Check-In Date] <= CurrentDate
&& Stays[Checkout Date] > CurrentDate
)
)
Guest is counted if:
Checked in on or before the night
Checked out after the night
Checkout day is not counted (standard hotel logic)
Create a Table visual:
Rows → Calendar[Date]
Values → Guests Occupied
(Optional: filter dates where Guests > 0)
=================================================================
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Jaywant Thorat | MCT | Data Analytics Coach
LinkedIn: https://www.linkedin.com/in/jaywantthorat/
Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
#MissionPowerBIBharat
LIVE with Jaywant Thorat from 10 Jan 2026
8 Days | 8 Sessions | 1 hr daily | 100% Free
This is a classic occupancy / hotel nights problem and it’s 100% solvable with DAX, without exploding dates into rows.
You already have:
Fact table: Stays (Guest ID, Check-In Date, Checkout Date)
Date table: Calendar[Date]
Create ONE relationship only:
Calendar[Date] → Stays[Check-In Date] (active)
(Checkout date will be handled in DAX, not relationships)
Create this measure:
Guests Occupied =
VAR CurrentDate =
SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
CALCULATE (
DISTINCTCOUNT ( Stays[Guest ID] ),
FILTER (
ALL ( Stays ),
Stays[Check-In Date] <= CurrentDate
&& Stays[Checkout Date] > CurrentDate
)
)
Guest is counted if:
Checked in on or before the night
Checked out after the night
Checkout day is not counted (standard hotel logic)
Create a Table visual:
Rows → Calendar[Date]
Values → Guests Occupied
(Optional: filter dates where Guests > 0)
=================================================================
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Jaywant Thorat | MCT | Data Analytics Coach
LinkedIn: https://www.linkedin.com/in/jaywantthorat/
Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
#MissionPowerBIBharat
LIVE with Jaywant Thorat from 10 Jan 2026
8 Days | 8 Sessions | 1 hr daily | 100% Free
Please try the formula below:
Guests (Occupied Nights) =
VAR d = MAX ( DimDate[Date] )
RETURN
CALCULATE (
DISTINCTCOUNT ( Stays[Guest ID] ),
FILTER (
ALL ( Stays ),
Stays[Check-In Date] <= d
&& Stays[Checkout Date] > d
)
)
Hello @ihatethis
Daily Occupancy =
VAR SelectedDate = MAX('Date'[Date])
RETURN
CALCULATE(
COUNTROWS('GuestTable'),
FILTER(
'GuestTable',
'GuestTable'[Check-In Date] <= SelectedDate &&
'GuestTable'[Checkout Date] > SelectedDate
)
)
If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.
Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn
Hi @ihatethis
if this is what you are looking for based on the data you gave (hope I interpreted dates in the right way)
you can find my file here
https://drive.google.com/drive/folders/16Qg6qfKEShGp7AEsdnM8CecoV3xD6CiP?usp=drive_link
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 60 | |
| 59 | |
| 45 | |
| 17 | |
| 17 |
| User | Count |
|---|---|
| 115 | |
| 112 | |
| 38 | |
| 35 | |
| 26 |