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: 
Not applicable

Load distinct record

Hi, I am now having a table containing three fields like the following.

 

userIdiptime
1234192.188.1.12012-02-02
1234192.234.1.12012-03-01
2345192.345.3.22012-02-02
2345188.134.2.32012-04-09

What I would like to do is to load this table with only the latest ip address for a particular user. After loading, the table should look like something like below.

userIdiptime
1234192.234.1.12012-03-01
2345188.134.2.32012-04-09

Initially, I was trying to user aggregation function. What i did is

load userId,

       ip,

       max(time)

from table group by userId.

But it doesn't work. Could anyone help me on this?

1 Solution

Accepted Solutions
Not applicable
Author

Hi, I found the answer. The script i use is:

table:

load userId,

        ip,

        time

from xxx;

load userId,

       lastValue(ip),

       max(time)

resident table group by userId order by time;

drop table table;

By using a resident table, I am able to order the time first before i retrieve the last loaded record. Thanks all for help:)

Regards,

Xue Bin

View solution in original post

7 Replies
Not applicable
Author

try with:

load userId,

        lastvalue(ip),

        max(time)

from table group by userId;

Hope this help you.

Not applicable
Author

HI,PLEASE FIND THE ATTACHED QVW.

Not applicable
Author

Hi theFourth,

   Your solution gives me some hint. But it assumes that the the records are ordered by time right? I tried to change the order of the records and your solution fails. Any way to order the time after a group statement?

Regards,

Xue Bin

Not applicable
Author

Sorry Jatin,

 

     The previous reply was meant for theFourth. I wrote the name wrongly. Could you post your code here as I have a qlikview personal edition and am unable to open your document. Thanks:)

Regards,

Xue Bin

Not applicable
Author

Hi, I found the answer. The script i use is:

table:

load userId,

        ip,

        time

from xxx;

load userId,

       lastValue(ip),

       max(time)

resident table group by userId order by time;

drop table table;

By using a resident table, I am able to order the time first before i retrieve the last loaded record. Thanks all for help:)

Regards,

Xue Bin

SunilChauhan
Champion II
Champion II

take a pivot table

in dimension

user ID

Ip

and in expression

Maxstring(time)

hope this helps

Sunil Chauhan
Not applicable
Author

Hi Sunil,

   Thanks for your reply. What I was trying to do does not involve visualization. I just wanted to import from a file in specified requirement. Thanks:)

Regards,

Xue Bin