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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
datbrink
New Member

Calculating Average Occupancy Between Times

Hello PBI Professionals, 

 

I am attempting to create a stacked column chart where I will display the average meeting room utilization every 15 minutes. I have a "Start Time" and an "End Time" variable as is seen below. I will be using the "Type" column in the legend. If a room is being used from 12:15:00 PM to 12:45:00 PM then this room would apply for the 12:15:00,12:30:00, and 12:45:00 values. 

 

Start TimeEnd TimeQtyType
9:27:00 AM3:17:00 PM1Student
8:15:00 AM2:14:00 PM1Professional
7:23:00 AM4:15:00 PM1Professional
2:30:00 AM3:15:00 PM1Professional
12:15:00 PM12:45:00 PM1Student

 

I have already created a separate time table that holds a 15 minute incremental count from 00:00:00 to 23:45:00. This has a column titled 'time15'. 

 

How might I go about creating the average count by hour? I created a model that shows me the exact utilization by 15 minute increment by day, but I want to create a model that only shows the average per 15 minute increment regardless of day. In my exact model I used the "Qty" column with a COUNTA() function. The following image is an example of what I created with an exact count. Ideally, the chart with the average would have a max value of 45 on the y-axis rather than 20,000 as is seen in the exact count. 

 

datbrink_0-1643824636831.jpeg

 

 

Unfortunately I am limited on how much data I can share due to confidentiality. 

 

My original DAX code for the measure used to obtain the exact count is: 

Measure = CALCULATE(COUNTA(data[Qty]),FILTER(data,data[Start Time] <= SELECTEDVALUE('timetable'[time15]) && SELECTEDVALUE('timetable'[time15]) <= data[End Time]))

 

I would appreciate any help that can be provided. I cannot seem to get past this, and I feel like I have tried everything. 

 

Thank you in advance. 

 

1 ACCEPTED SOLUTION

Hi @datbrink ,

 

per room per day.

I think you are only counting the number of occurrences of this room within these dates. If you want to calculate the average, how many days are there within these dates. 

Total number of occurrences / total number of days

Measure :

 

Room_Counter =
DIVIDE(
    COUNTROWS(
        FILTER(
            RawData,
            RawData[Start Time] <= SELECTEDVALUE( 'DateTime Table'[Datetime] )
                && SELECTEDVALUE( 'DateTime Table'[Datetime] ) <= RawData[Stop Time]
        )
    ),
    COUNTROWS( VALUES( RawData[Start Date] ) )
)

 

 

Pbix file in the end.

Best Regards

Community Support Team _ chenwu zhu

 

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

8 REPLIES 8
AlexisOlson
Super User
Super User

If you want an average per room per day, then you need to divide by the number of rooms and the number of days selected.

Alexis, 

 

Thank you for your response. The "Qty" column only has a value of 1 per room per day, which work has worked well when using a COUNTA function. Everytime that I think I have solved the average, it displays the "Student" and "Professional" values from the "Type" column as 1s for hte entire chart, meaning it is now flat and shows no trends regarding utilization by hour. 

 

Any ideas on how I can move beyond this? 

Can you share a sample pbix (with any sensitive information scrubbed)? The one set of data rows you provided isn't quite enough to work with.

Alexis, 

 

Here is a link to the file. Please let me know if you have any questions or concerns. 

 

https://drive.google.com/file/d/1gvQvYLKHba0dMHh5oQy-sN-he9-A6iIj/view?usp=sharing

 

 

Hi @datbrink ,

 

per room per day.

I think you are only counting the number of occurrences of this room within these dates. If you want to calculate the average, how many days are there within these dates. 

Total number of occurrences / total number of days

Measure :

 

Room_Counter =
DIVIDE(
    COUNTROWS(
        FILTER(
            RawData,
            RawData[Start Time] <= SELECTEDVALUE( 'DateTime Table'[Datetime] )
                && SELECTEDVALUE( 'DateTime Table'[Datetime] ) <= RawData[Stop Time]
        )
    ),
    COUNTROWS( VALUES( RawData[Start Date] ) )
)

 

 

Pbix file in the end.

Best Regards

Community Support Team _ chenwu zhu

 

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

Hmm. There are over 100 rows for 9/9/2021 that include 9 AM. Since there is no room number assigned to any rows, I can't tell if you have lots of people in a few rooms or you have over 100 rooms. It's not possible to compute utilization percent without knowing how many rooms are involved since that number needs to be in the denominator.

For clarification purposes, I have multiple locations (more than 20) with their own set of rooms that are being analyzed, but I have scrubbed that data for the sake of confidentiality. Would there be a way to set the denominator equal to a measure that changes the count of active rooms based on how I may be filtering?

 

For example, if we are looking at the example file I gave you, could we create a measure that calculates the AVERAGE(COUNTA(Qty) by day by binned hour to tell us how many rooms, on the average day, are being utilized in the specified 15 minute bin? 

 

Sorry this is so convoluted, I am very new to this program and only have prior experience with R. 

If each row had the proper identifiers, you can divide by a DISTINCTCOUNT of that ID, which can be filtered (or unfiltered) according to your preference.

 

In summary, yes. If you have the relevant fields, then it's certainly possible to include them in the denominator.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.