Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Time Extraction

Dear all,

I am having a field say TimeStamp which stores intime(AM) and outime(PM) of a person.

Sample:   PersonName  TimeStamp

                  ABC             8:35:02 AM

                  ABC             5:32:04 PM

I want to represent TimeStamp filed into two fields say InTime and OutTime w.r.t person.

Format:          PersonName        InTime            OutTime

                       ABC              8:35:02 AM          5:32:04 PM

Reply me ASAP.

Regards,

Balraj Ahlawat

20 Replies
anbu1984
Master III
Master III

Load PersonName,Min( TimeStamp) As InTime, Max( TimeStamp) As OutTime

From Src.xlsx

Group by PersonName

Anonymous
Not applicable
Author

Anbu,

I am having multiple fields in that table, your expression is ok when you are having two fields say PersonName and TimeStamp.

What to do when I have 10+ fields in the same table?

Regards,

Balraj Ahlawat

Anonymous
Not applicable
Author

Anbu,

One more thing I want to add, these two fields are into two separate tables.

Regards,

Balraj Ahlawat

SunilChauhan
Champion II
Champion II

take one more table which is resident to original and having above two field

Sunil Chauhan
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Just create a new field which identifies Intime and Outime, something like shown below.

     Load *,if(right(TimeStamp)  = 'PM','Out Time','In Time') as InOutFlag from xyz.

     Now on qlikview sheet create a pivot table with all required fields and expression as only(TimeStamp)

     Now drag the field (InOutFlag) on top of the TimeStamp expression and drop it there.

     So now you will have the table with the format you want.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

Kaushik,

Some peoples are there who log in when time is into PM say 2nd half as well.

What is the solution for that?

Regards,

Balraj Ahlawat

anbu1984
Master III
Master III

If you have more fields to select along with min and max values, then you can try analytic function like below

Load PersonName,Min( TimeStamp) Over(Partition by PersonName) As InTime, Max( TimeStamp) Over(Partition by PersonName) As OutTime, Fld2, Fld3...

From Table

How do you join Tables having times to your main table?

its_anandrjs

Load your table like below script and if not required Source table then drop the table at last

Source:

LOAD Time(TimeStamp,'hh:mm:ss TT') AS TimeStamp,PersonName;

LOAD * INLINE [

    PersonName,  TimeStamp

    ABC,             8:35:02 AM

    ABC,             5:32:04 PM

];

Final:

LOAD

PersonName, 

Time( Min(TimeStamp)) AS Min

Resident Source

Group By PersonName;

Left Join

LOAD

PersonName, 

Time(Max(TimeStamp)) AS Max

Resident Source

Group By PersonName;

Drop table Source; // If required drop this table.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

     How do you identify such transactions.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!