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

How to add time to working days with its working hours, excluding weekend,holidays and no work hours

Hi everyone, this is my first post

i'm currently working on Power Bi for some simple reports that i need, im manipulating dates.

 

the problem is: i have a Initial date, but from that date i need to sum a time that can be minutes to a lots of hours, and the work hours of one day is 7:30 A.M to 17:30 P.M. The weekend and holidays must be validated also.

i read some post in community.powerbi , with the calendar + holidays table, but i can solve my problem at all, ths is the post i read https://community.powerbi.com/t5/Desktop/Add-working-days-to-a-date/td-p/146945

A
n example may be: 

InitialDate                            WorkHours        FinalDate
12/4/2018 17:20:00 P.M       7:50:00              12/5/2018 15:10:00 P.M

 

then, i have this problem, can you help me with this? thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use following calculate column formula to calculate end date based on 'initial date' and 'work hours': 

EndDate =
VAR _todayRemain =
    TIME ( 17, 30, 00 )
        - MAX (
            TIME ( 7, 30, 00 ),
            MIN ( TIME ( 17, 30, 00 ), TIMEVALUE ( [InitialDate] ) )
        )
VAR _totalWorkhours =
    IF (
        WEEKDAY ( [InitialDate], 2 ) <= 5,
        [Work Hours] - _todayRemain,
        [Work Hours]
    )
VAR _workDays =
    IF (
        _totalWorkhours > 0,
        INT ( _totalWorkhours / 10 )
            + IF ( MOD ( _totalWorkhours, 10 ) > 0, 1, 0 ),
        0
    )
VAR _remaintime =
    _totalWorkhours
        - INT ( _totalWorkhours / 10 )
            * _totalWorkhours
VAR _holidayoffset =
    IF ( WEEKDAY ( [InitialDate], 2 ) >= 5, 7 - WEEKDAY ( [InitialDate], 2 ), 0 )
RETURN
    DATEVALUE ( [InitialDate] ) + _holidayoffset
        + _workDays
        + TIME ( 7, 30, 0 )
        + _remaintime

 10.png

 

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use following calculate column formula to calculate end date based on 'initial date' and 'work hours': 

EndDate =
VAR _todayRemain =
    TIME ( 17, 30, 00 )
        - MAX (
            TIME ( 7, 30, 00 ),
            MIN ( TIME ( 17, 30, 00 ), TIMEVALUE ( [InitialDate] ) )
        )
VAR _totalWorkhours =
    IF (
        WEEKDAY ( [InitialDate], 2 ) <= 5,
        [Work Hours] - _todayRemain,
        [Work Hours]
    )
VAR _workDays =
    IF (
        _totalWorkhours > 0,
        INT ( _totalWorkhours / 10 )
            + IF ( MOD ( _totalWorkhours, 10 ) > 0, 1, 0 ),
        0
    )
VAR _remaintime =
    _totalWorkhours
        - INT ( _totalWorkhours / 10 )
            * _totalWorkhours
VAR _holidayoffset =
    IF ( WEEKDAY ( [InitialDate], 2 ) >= 5, 7 - WEEKDAY ( [InitialDate], 2 ), 0 )
RETURN
    DATEVALUE ( [InitialDate] ) + _holidayoffset
        + _workDays
        + TIME ( 7, 30, 0 )
        + _remaintime

 10.png

 

Regards,

Xiaoxin Sheng

How can I add 25 hours of working time to that? I tried using the value '25' in space [Work Hours] but didn't work. Also tried Time(25, 00, 00) but none of them made it ok.

 

Example: 28/07/2023 16:23:55 -> 02/08/2023 10:59:55

Any help?

Anonymous
Not applicable

hi @Anonymous  Xiaoxin

Thank you, it worked!! excelent answer!

a time ago a wasn't able to reply because of work, but now i appreciate you help!!! 😄 

adambhappy
Resolver II
Resolver II

What is your data source? Is it import or DirectQuery?

Anonymous
Not applicable

is and excel sheet, a column names "FechaInicial" and "TiempoHabil" is given to me to do the calculation

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.