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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load first 2 records in a group

Hi,

anyone have any idea how to load only the first 2 records according to the latest birthday of every group?

Expected Result:

For Group 1, Alice,Jon

For Group 2, David,Derrick

For Group 3, Serene,Rachel

Dataset:

NameBirthdayGroup
Alice01/01/871
David02/03/872
Jason29/04/873
Jon01/04/871
Derrick03/05/872
Aaron17/07/872
Jerome20/09/871
Serene23/02/873
Rachel21/04/873

Thank you.

4 Replies
kumarnatarajan
Partner - Specialist
Partner - Specialist

Hi,

Load below script.

LOAD * Where WildMatch(AutoNumber(Group&RowNo(),Group),1,2);

LOAD * INLINE [

    Name, Birthday, Group

    Alice, 01/01/87, 1

    David, 02/03/87, 2

    Jason, 29/04/87, 3

    Jon, 01/04/87, 1

    Derrick, 03/05/87, 2

    Aaron, 17/07/87, 2

    Jerome, 20/09/87, 1

    Serene, 23/02/87, 3

    Rachel, 21/04/87, 3

];

I think For Group 3, Jason,Serene

Not applicable
Author

Group 3 should be Serene and Rachel because I will order by the birthday and get the first 2 records of it.

kumarnatarajan
Partner - Specialist
Partner - Specialist

Ok No prob. you can get result after using order by.

try below one.

Temp:

LOAD * INLINE [

    Name, Birthday, Group

    Alice, 01/01/87, 1

    David, 02/03/87, 2

    Jason, 29/04/87, 3

    Jon, 01/04/87, 1

    Derrick, 03/05/87, 2

    Aaron, 17/07/87, 2

    Jerome, 20/09/87, 1

    Serene, 23/02/87, 3

    Rachel, 21/04/87, 3

];

NoConcatenate

Temp2:

LOAD * Resident Temp Where WildMatch(AutoNumber(Group&RowNo(),Group),1,2) Order by Birthday;

DROP Table Temp;

SunilChauhan
Champion II
Champion II

see the attached file

hope this helps

Sunil Chauhan