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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

class interval from two hour

hi, sorry for my bad english, i have a big big problem !!

i have

operator
login
logout
Alex09:5011:30
Simon09:0010:30
Luca11:0112:00

i need to make a class hour for count minutes logged

range hour
operator
minutes logged
09:00 to 10:00Alex10
Simon60
10:00 to 11:00Simon30
11:00 to 12:00Luca59

usually for class 1 time i use

=dual(timestamp(class(frac(mytime)       ,vTimeRange/(24*60)),'hh:mm') & ' - ' &
  timestamp(class(frac(mytime)+vTimeRange/(24*60),vTimeRange/(24*60)),'hh:mm')
,      class(frac(mytime)       ,vTimeRange/(24*60)))

but with range 2 times i dont know !!???

how can i do ?

there are some exaples with class two datetimes ?

thanks

1 Reply
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

I'd calculate this in the script with something like this:

Data:

LOAD *, If(Hour<login, Interval(Hour+1/24-login,'m'),if(Hour+1/24< logout,1/24,logout-Hour)) as [Minutes logged];

LOAD *, Time(Floor(login + (IterNo()-1)/24, 1/24),'hh:mm') as Hour

While Floor(login + (IterNo()-1)/24,1/24) < logout;

LOAD

  operator,

  Time#(login,'hh:mm') as login,

  Time#(logout,'hh:mm') as logout

INLINE [

operator, login, logout

Alex, 09:50, 11:30

Simon, 09:00, 10:30

Luca, 11:01, 12:00

];

The inline load is just an example. You can replace that with a load statement that load the data from your real source table.


talk is cheap, supply exceeds demand