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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
alvinford
Contributor III
Contributor III

How can I derive Hours from Login and Logout

Hi All,

Also need help on the below.

I have the LoginTime  and LogoutTime need to Generate the Hours between the time in the New Column.

For Example : Taking the highlighted LoginTime and LogOut time i.e. 10:45:23 to 13:14:49 , Need to generate following hours between them i.e. 10,11,12,13 .

LoginTimeLogOutTime
10:09:08 AM10:18:20
10:13:54 AM10:34:26
10:18:46 AM12:19:18
10:22:06 AM11:06:49
10:32:54 AM16:15:54
10:44:11 AM13:12:11
10:45:23 AM13:14:49
10:48:58 AM12:37:48
10:52:21 AM12:39:28
10:58:15 AM11:03:14
10:59:52 AM11:24:11
10:59:57 AM11:49:22

How can I generate new column containing  Hours between the LoginTime and LogOut time ?

Regards,

Alvin.

12 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

Check with this script using while

Event:

LOAD

          Hour(LoginTime) AS HourLogin,

          Hour(LogOutTime) AS HourLogout,

          Hour(LoginTime) + IterNo() - 1 AS Hours,

          LoginTime,

          LogOutTime

While (Hour(LoginTime) + IterNo() - 1) <= Hour(LogOutTime) ;

LOAD * INLINE [

    LoginTime, LogOutTime

    10:09:08 AM, 10:18:20

    10:13:54 AM, 10:34:26

    10:18:46 AM, 12:19:18

    10:22:06 AM, 11:06:49

    10:32:54 AM, 16:15:54

    10:44:11 AM, 13:12:11

    10:45:23 AM, 13:14:49

    10:48:58 AM, 12:37:48

    10:52:21 AM, 12:39:28

    10:58:15 AM, 11:03:14

    10:59:52 AM, 11:24:11

    10:59:57 AM, 11:49:22

];

Hope it helps

Celambarasan

CELAMBARASAN
Partner - Champion
Partner - Champion

Check the attached qlikview file

Hope it helps

Celambarasan

Not applicable

Yes, there rows duplicated in my example.

Your example is nice, small and functional.