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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Start/end date and time occupancy in a matrix table

Hello

 

I have a bookings table with a start date, end date, start time and end time, the dates sometimes span multiple days.

 

I am trying to create a matrix table, with date and time in the columns and category booking in the rows. I want to count the booking occupancies across date and time and conditional format (i know how to do this bit) so the user has a clear view of when there is a booking and when there is not.

 

I have previously used the below DAX for a different table where bookings start date and end date were the same. This however does not seem to work for this new table where start/end dates differ.

 

Court in Play =
var MinTime = min('Time table 2'[Time])
var MaxTime = max('Time table 2'[Time])
var MinDate = min('Date Table'[Date])
var MaxDate = max('Date Table'[Date])
var CourtsInPLay2 = COUNTROWS(FILTER(ALLSELECTED('Reports uvw_Event'),'Reports uvw_Event'[StartTime]<=MinTime && 'Reports uvw_Event'[EndTime]>MaxTime && 'Reports uvw_Event'[StartDate]=MinDate && 'Reports uvw_Event'[EndDate]=MaxDate))
Return
CourtsInPLay2
 
Any help would be most appreciated!
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Sorry for replying late. Since you have a time table, you need to create a Date table and another calculated table to show the result:

Date Table = CALENDAR(MIN('Table'[Downtime start date]),MAX('Table'[Downtime end date]))
Final table = 
VAR tab =
    SUMMARIZE (
        CROSSJOIN (
            ADDCOLUMNS (
                CROSSJOIN ( 'Date Table', 'Time table' ),
                "A",
                    CONVERT ( [Date] & " " & [Time], DATETIME )
            ),
            ADDCOLUMNS (
                'Table',
                "Start",
                    CONVERT ( [Downtime start date] & " " & [Downtime strat time], DATETIME ),
                "End",
                    CONVERT ( [Downtime end date] & " " & [Downtime end time], DATETIME )
            )
        ),
        [Date],
        [Time],
        [A],
        [Count],
        [Start],
        [End]
    )
RETURN
    FILTER ( tab, [Start] <= [A] && [End] > [A] )

re1.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
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
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Sorry for replying late. Since you have a time table, you need to create a Date table and another calculated table to show the result:

Date Table = CALENDAR(MIN('Table'[Downtime start date]),MAX('Table'[Downtime end date]))
Final table = 
VAR tab =
    SUMMARIZE (
        CROSSJOIN (
            ADDCOLUMNS (
                CROSSJOIN ( 'Date Table', 'Time table' ),
                "A",
                    CONVERT ( [Date] & " " & [Time], DATETIME )
            ),
            ADDCOLUMNS (
                'Table',
                "Start",
                    CONVERT ( [Downtime start date] & " " & [Downtime strat time], DATETIME ),
                "End",
                    CONVERT ( [Downtime end date] & " " & [Downtime end time], DATETIME )
            )
        ),
        [Date],
        [Time],
        [A],
        [Count],
        [Start],
        [End]
    )
RETURN
    FILTER ( tab, [Start] <= [A] && [End] > [A] )

re1.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tex628
Community Champion
Community Champion

Hi @Anonymous , 

Give this a try:

Court in Play = 
var MinTime = min('Time table 2'[Time])
var MaxTime = max('Time table 2'[Time])
var MinDate = min('Date Table'[Date])
var MaxDate = max('Date Table'[Date])
var CourtsInPLay2 = 
COUNTROWS(
FILTER(ALLSELECTED('Reports uvw_Event'),
'Reports uvw_Event'[StartTime]<=MinTime && 
'Reports uvw_Event'[EndTime]>MaxTime && 
'Reports uvw_Event'[StartDate]<=MinDate && 
'Reports uvw_Event'[EndDate]>=MaxDate)
)
Return
CourtsInPLay2

 


Connect on LinkedIn
Anonymous
Not applicable

Thanks for response. 

 

When i try this way, Its not filtering by category, and so all values in each row are the same?

amitchandak
Super User
Super User

@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

refer if this blog can help

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-or-end-date/ba-p/1503785

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

GSawd2112_0-1612784482157.png

GSawd2112_1-1612784504378.png

Hi, hope these screenshots help as a simple example?

@Anonymous , Create an hour table using generate series

 

Time = addcolumn ( generateseries(0,24) , "Time", time(0,[value],0))

 

And follow the steps in blog, place dates and date table m use start time and time and time table

 

In case you need a table, find the file attached after signature

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi,

 

I have the hour by hour table, I can I incorporate this into the table, to allow me to drill down for an hour by hour view?


Thanks in advance

Anonymous
Not applicable

Thanks for your speedy responses!

 

I used the table2 dax in your attachment which has been helpful. Am i able to incorporate my time table into this expression as well?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors