Forum Discussion

shado26's avatar
shado26
Helper III
8 years ago

Exclude Weekend and working hours

Dear Team

 

appreciate your assist to upgrade below formula to exclude Weekend and working hours attached test file 

 

Test PBIX File

 

i have been used the below formula 

 

Time Diff2 = VAR PreviousTime=TOPN(1,Filter(Table1,Table1[Orderno]=earlier(Table1[Orderno])&&Table1[LogDatetime]<earlier(Table1[LogDatetime])),[LogDatetime],desc)
RETURN
DATEDIFF(MINX(PreviousTime,Table1[LogDatetime]),Table1[LogDatetime],SECOND)
Duration = 
VAR TotalSeconds=SUM(Table1[Time Diff2])
VAR Days =TRUNC(TotalSeconds/3600/24)
VAR Hours = TRUNC((TotalSeconds-Days*3600*24)/3600)
VAR Mins =TRUNC(MOD(TotalSeconds,3600)/60)
VAR Secs = CEILING(MOD(TotalSeconds,60),1)
return IF(DAYS=0,"",IF(DAYS>1,DAYS&" days "))&IF(Hours<10,"0"&Hours,Hours)&" hours "&IF(Mins<10,"0"&Mins,Mins)&" minutes "&IF(Secs<10,"0"&Secs,Secs)&" seconds "

10 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi shado26

    As I understand, when excluding Weekend and working hours, the second row of "Time Diff2" would change to be 0 instead of 38.

    Since excluding Weekend and working hours means excluding any time in Saturday and Sunday, along with time period of 8:00 -18:00 of each day from Monday to Friday.

    Is my understanding right?

     

    Best Regards

    Maggie