Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

get only first record of user

hi,

I had some datase like below

load * inline

[networkid, user, timestamp

n1,u1,1

n1,u2,2

n1,u3,3

n2,u1,2

n2,u2,3

n2,u3,1

n3,u1,3

n3,u2,2

n3,u3,1

n2,u1,3

n1,u1,3]
;

now i need to get only first record of user based on timestamp

something as below.

users          timestamp(max)          network

u1                         3               n3

u2                         3                   n2

u3                          3                    n1

I am able to get this in front end(sheet).but i need to get this in script part only

please help me how to acheive this

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Table1:

load * inline

[networkid, user, timestamp

n1,u1,1

n1,u2,2

n1,u3,3

n2,u1,2

n2,u2,3

n2,u3,1

n3,u1,3

n3,u2,2

n3,u3,1

n2,u1,3

n1,u1,3];

Table2:

load user, max(timestamp) as TimestampMax, firstsortedvalue(networkid, -timestamp) as Network

resident Table1

group by user;


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
salto
Specialist II
Specialist II

Hi,

have a look at the firstsortedvalue command.

After you load the inline, try with:

Load user,

firstsortedvalue(network, timestamp) as FirstTimeStamp resident InlineTableName,

group by user;

Regards.

Gysbert_Wassenaar

Table1:

load * inline

[networkid, user, timestamp

n1,u1,1

n1,u2,2

n1,u3,3

n2,u1,2

n2,u2,3

n2,u3,1

n3,u1,3

n3,u2,2

n3,u3,1

n2,u1,3

n1,u1,3];

Table2:

load user, max(timestamp) as TimestampMax, firstsortedvalue(networkid, -timestamp) as Network

resident Table1

group by user;


talk is cheap, supply exceeds demand
MayilVahanan

HI

Try like this

Load user,

firstsortedvalue(network, -timestamp) as FirstTimeStamp resident InlineTableName,

group by user;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

got it worked wasaneer. thank u so much