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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
ihatethis
New Member

Average daily Occupancy with only start and end date (on dates WITH occupancy)

I have two tables: a Date Table and a Stays Table

 

The stays table has the guest, the room, and the check-in date, and the check-out date. From a previous post, I had help getting the guests per night across date ranges, but now I'm struggling to get the service dates to calculate the average occupancy per day and per bed. I couldn't use the same filter logic to bring in all the unique dates between the checkin and checkout dates. 

 

If no one stays in a building, I want to be able to exclude that date from that building's occupancy (we only want to measure occupany when that building is in-use)

 

Stays Table 

GuestIDBuildingBed IDCheck-In DateCheckout Date
1110001/01/202601/08/2026
2210201/01/202601/05/2026
3110412/31/202501/10/2026
4110601/02/202601/03/2026
521001/08/202601/10/2025

 

Date Table (spans >365 days)

Date
01/01/2026
Etc.

 

Output Wanted

  • Average Daily Occupancy (per building, per date in use)
BuildingAverage Daily Occupancy
Building 11.6 (to round up to 2)
Building 21

 

 

previous post re: daily occupancy 

1 ACCEPTED SOLUTION
cengizhanarslan
Super User
Super User

Step 1 – Occupancy per building per day

This counts how many beds are occupied on a given date.

Daily Occupancy =
VAR CurrentDate = SELECTEDVALUE ( 'Date'[Date] )
RETURN
CALCULATE (
    DISTINCTCOUNT ( Stays[Bed ID] ),
    FILTER (
        Stays,
        Stays[Check-In Date] <= CurrentDate
            && Stays[Checkout Date] > CurrentDate
    )
)

If you put Date + Building in a table, this will show the correct nightly occupancy.

 

Step 2 – Average Daily Occupancy (excluding zero days)

Now we average only over dates where occupancy > 0 for that building.

Average Daily Occupancy :=
VAR OccupiedDates =
    FILTER (
        VALUES ( 'Date'[Date] ),
        [Daily Occupancy] > 0
    )
RETURN
AVERAGEX (
    OccupiedDates,
    [Daily Occupancy]
)

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

2 REPLIES 2
cengizhanarslan
Super User
Super User

Step 1 – Occupancy per building per day

This counts how many beds are occupied on a given date.

Daily Occupancy =
VAR CurrentDate = SELECTEDVALUE ( 'Date'[Date] )
RETURN
CALCULATE (
    DISTINCTCOUNT ( Stays[Bed ID] ),
    FILTER (
        Stays,
        Stays[Check-In Date] <= CurrentDate
            && Stays[Checkout Date] > CurrentDate
    )
)

If you put Date + Building in a table, this will show the correct nightly occupancy.

 

Step 2 – Average Daily Occupancy (excluding zero days)

Now we average only over dates where occupancy > 0 for that building.

Average Daily Occupancy :=
VAR OccupiedDates =
    FILTER (
        VALUES ( 'Date'[Date] ),
        [Daily Occupancy] > 0
    )
RETURN
AVERAGEX (
    OccupiedDates,
    [Daily Occupancy]
)

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

thank you! this was exactly what I needed!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.