Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load Record with Max value only

From the following script, i only want to load the record with the max setupdate


I am really struggling making others' answers work for my application.It's a simple thought...so i'm sure someone has a simple answer

Temp:

LOAD * INLINE [

    Company, Contact, SetupDate, Source,   RecNo

    1,  David,   41607,    AMP,       123

    1,  Tom,     41609,    Label,     456

    1,  Mary,    41610,    Internet,  789

    2,  Joe,    40600,    Referral,   1011

    3,  Tom,    41666,    Internet,   1213

    3,  Peter,   40600,    AMP,       1415

];

I want to return all fields, Company, Contact, Source, Recno ...but only the one with the max date. (By company)

Final:

LOAD * INLINE [

    Company, Contact, SetupDate, Source,   RecNo

    1,  Mary,    41610,    Internet,  789

    2,  Joe,    40600,    Referral,   1011

    3,  Tom,    41666,    Internet,   1213

];

so i should return 3 records...the 3rd, 4th, and 5th records based on the setupdate by company. I want to do this in the script, please help

-David

11 Replies
Clever_Anjos
Employee
Employee

tmp:

LOAD * INLINE [

    Company, Contact, SetupDate, Source,   RecNo

    1,  David,   41607,    AMP,       123

    1,  Tom,     41609,    Label,     456

    1,  Mary,    41610,    Internet,  789

    2,  Joe,    40600,    Referral,   1011

    3,  Tom,    41666,    Internet,   1213

    3,  Peter,   40600,    AMP,       1415

];

filter:

inner keep load

    Company,

    max(SetupDate) as SetupDate

resident tmp

group by Company;

drop table filter;

Not applicable
Author

The inner keep option is amazing and simple! Thank you very much QV friends