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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Custom Time Intervals

Hi,

 

I've got a few DateTime columns:

  • Job Booking datetime
  • Attempted Acceptance datetime
  • Acceptance datetime

For the time differences between them e.g. time between Job Booking to Attempted Accepted, time between Job Booking to Acceptance; I need to categorize these time differences into the following time intervals:

  • 0-2hrs
  • 2-4hrs
  • 5-12hrs
  • 12-24hrs
  • >24hrs

Here is sample data

 

Hope that made sense. Appreciate any help.

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@Mariusz thank you, appreciate it

View solution in original post

Hi @Anonymous ,

If (WEEKDAY(Date, 2) = 6 || WEEKDAY(Date,2) = 7, “”,The formula applied above)

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can try to add two columns like below.

Acceptance = 
IF( 
    NOT ISBLANK( 'Table'[ACCEPTANCE_DATETIME] ),
    VAR _hrs = HOUR( 'Table'[ACCEPTANCE_DATETIME] - 'Table'[JOB_BOOKING_DATETIME] )
    RETURN 
        SWITCH(
            TRUE(),
            _hrs >= 0 && _hrs <= 2, "0-2hrs",
            _hrs >= 3 && _hrs <= 4, "3-4hrs",
            _hrs >= 5 && _hrs <= 12, "5-12hrs",
            _hrs >= 13 && _hrs <= 24, "13-24hrs",
            ">24hrs"
        )
)
Attempted = 
IF( 
    NOT ISBLANK( 'Table'[ATTEMPTED_ACCEPTANCE_DATETIME] ),
    VAR _hrs = HOUR( 'Table'[ATTEMPTED_ACCEPTANCE_DATETIME] - 'Table'[JOB_BOOKING_DATETIME] )
    RETURN 
        SWITCH(
            TRUE(),
            _hrs >= 0 && _hrs <= 2, "0-2hrs",
            _hrs >= 3 && _hrs <= 4, "3-4hrs",
            _hrs >= 5 && _hrs <= 12, "5-12hrs",
            _hrs >= 13 && _hrs <= 24, "13-24hrs",
            ">24hrs"
        )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Anonymous
Not applicable

@Mariusz thank you for quick response. I notice the two column functions are exactly the same or am I missing something?

 

Or did you mean one column for Acceptance datetime and the other for Attempted Acceptance datetime?

Hi @Anonymous 

 

 

Sorry, yes I've adjusted my post.

 

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

Anonymous
Not applicable

@Mariusz thank you, appreciate it

Anonymous
Not applicable

Hi @Mariusz how do I exclude weekends (Sat & Sun) from this function? 

i.e. if Job_Booking_DateTime is on Sat or Sun, then exclude from calculation

Hi @Anonymous ,

If (WEEKDAY(Date, 2) = 6 || WEEKDAY(Date,2) = 7, “”,The formula applied above)

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you @Nathaniel_C , just wasn't sure where to wrap that formula in the current function. Thanks for clarifying, appreciate it.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.