Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Working hours -

Hi all, here's a mystery. I'm trying to calculate the working hours between two dates:

Start Time and End Time.

here's the script:

Interval(

     rangesum(

          NetWorkDays(start_time+1,End_time-1,$(vHol)) * MakeTime(10)  

     ,if(NetWorkDays(End_time,End_time,$(vHol)),Rangemin(rangemax(frac(End_time),maketime(8)),maketime(18))-Rangemax(rangemin(frac(End_time),maketime(8)),maketime(8)),0) // working hours last day

,if(NetWorkDays(start_time,start_time,$(vHol)),Rangemin(rangemax(frac(start_time),maketime(18)),maketime(18))-Rangemax(rangemin(frac(start_time),maketime(18)),maketime(8)),0) // working hours first day

,if(NetWorkDays(start_time,start_time,$(vHol)) and floor(start_time)=floor(End_time),-MakeTime(10))

)

)

as WorkingHours

Then the Expresion

SUM({$<WorkingHours=  {"$(='>' & '00:00:00' & '<' & '08:00:00')"}, GroupID={'2'}>} Value)

table.jpg

As you can see in the picture there are some values that aren't fitting into the <8 hours:

Start = End time is 0 and no clue why, next one is 00:03:05 (far away from 08:00:00) but also doesn't come into <8. Expresion is workin 'cos there are others working

Any idea? some clues?

Best regards!

1 Reply
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

It looks to me that you're comparing an interval value with strings. I doubt that is correct. Perhaps this works better:

     SUM({$<WorkingHours=  {">=$(=Time(MakeTime(0)))<$(=Time(MakeTime(8)))"}, GroupID={'2'}>} Value)

If that also does not work then please post a small qlik sense app that demonstrates the problem.


talk is cheap, supply exceeds demand