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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Busy times for reservaitons

Hello to all,

I have the start and end time ranges of reservations. Based on these, I want to calculate how many reservations are made in 1-hour intervals in 24 hours. If the reservation is for two hours, I want to calculate it in the interval of two hours. For example, I have a reservation between 9 PM and 11 PM, I want to add this one 9-10 PM and 10-11 PM slots. Is it possible to calculate this way? Thank you for your help. 

 

demderballsquad_0-1655889959494.png

 

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Anonymous I'm attaching the file with the solution: Busy times for reservaitons.pbix
I created a parameter time table and this measure:

 

# Reservations = 
VAR _start_slot = SELECTEDVALUE('Dim Times'[Time Bucket])
VAR _end_slot = _start_slot + TIME(0,0,59) 
VAR _result = 
CALCULATE(
    COUNTROWS('Table'),
    KEEPFILTERS(
        FILTER(
            'Table',
            VAR _start_time = 'Table'[Start_Time - Copy]
            VAR _end_time = IF( 'Table'[End_Time - Copy] <> 0, 'Table'[End_Time - Copy], TIME(23,59,0))
            RETURN
            _start_time <= _start_slot && _end_time >= _end_slot
        )
    )
)
RETURN
    _result

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

3 REPLIES 3
SpartaBI
Community Champion
Community Champion

@Anonymous I'm attaching the file with the solution: Busy times for reservaitons.pbix
I created a parameter time table and this measure:

 

# Reservations = 
VAR _start_slot = SELECTEDVALUE('Dim Times'[Time Bucket])
VAR _end_slot = _start_slot + TIME(0,0,59) 
VAR _result = 
CALCULATE(
    COUNTROWS('Table'),
    KEEPFILTERS(
        FILTER(
            'Table',
            VAR _start_time = 'Table'[Start_Time - Copy]
            VAR _end_time = IF( 'Table'[End_Time - Copy] <> 0, 'Table'[End_Time - Copy], TIME(23,59,0))
            RETURN
            _start_time <= _start_slot && _end_time >= _end_slot
        )
    )
)
RETURN
    _result

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Anonymous
Not applicable

Hello, this is amazing. It's work, thanks a lot 🙏

@Anonymous my pleasure 🙂
Hey, check out my showcase report - got some high level stuff there 🙂
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.