Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
pauldamen
Partner - Creator II
Partner - Creator II

Load only first record per ID

All,

I have a dataset which looks like this:

ID          Status               Date

1               Declined          1/1

1               Declined          3/1

1               Approved          5/1

2               Approved       1/1

3               Declined          2/1

3               Approved          3/1

What I need is only to load the first record of every ID, so I get this load:

ID          Status               Date

1               Declined          1/1

2               Approved      1/1

3               Declined          2/1

How can I achieve this?

Regards,

Paul

1 Solution

Accepted Solutions
MarcoWedel

Hi,

another solution might be:

QlikCommunity_Thread_249677_Pic1.JPG

tabTemp:

LOAD * INLINE [

    ID, Status, Date

    1, Declined, 1/1

    1, Declined, 3/1

    1, Approved, 5/1

    2, Approved, 1/1

    3, Declined, 2/1

    3, Approved, 3/1

];

NoConcatenate

table1:

LOAD * Resident tabTemp

Where ID<>Previous(ID)

Order By ID, Date;

DROP Table tabTemp;

hope this helps

regards

Marco

View solution in original post

17 Replies
pipuindia99
Creator III
Creator III

Hi,

Try this

load

firstsortedvalue(ID) as ID,

status,

Date

from table name group by status, date;

Anonymous
Not applicable

LOAD

firstsortedvalue(Date,Date) as Date,

firstsortedvalue(Status,Date) as Status,

ID

resident...

group by ID;

-------------------------

But you have to be carefull, when the first sorted value isn't unique within each dimension.

pipuindia99
Creator III
Creator III

Hi,

sorry, Try the below one

load

firstsortedvalue(ID , ID) as ID,

status,

Date

from table name group by status, date;

pauldamen
Partner - Creator II
Partner - Creator II
Author

I still get multiple lines for each ID. Please find my workbook attached

pipuindia99
Creator III
Creator III

Have you attached your workbook? because i could not find it

Anonymous
Not applicable

LOAD * INLINE [
ID, Status, Date
1, Declined , 1/1
1, Declined , 3/1
1, Approved, 5/1
2, Approved, 1/1
3, Declined , 2/1
3, Approved, 3/1
]

Where not Exists(ID); 


(works only, if your table is sorted the correct way, but you said, you want the first record)

sunny_talwar

You can try this:

Table:

LOAD * INLINE [

    ID, Status, Date

    1, Declined, 1/1

    1, Declined, 3/1

    1, Approved, 5/1

    2, Approved, 1/1

    3, Declined, 2/1

    3, Approved, 3/1

];

Right Join (Table)

LOAD ID,

  Min(Date) as Date

Resident Table

Group By ID;

pauldamen
Partner - Creator II
Partner - Creator II
Author

Sorry closed the browser to fast

sunny_talwar

Try this:

FirstValue:

LOAD Winkelwagen as ID,

  FirstSortedValue(Status, -[Aanmaak/herzien datum]) as Status,

     Date(Min([Aanmaak/herzien datum])) as Date

FROM

[Workflow rapportage SRM v0.2.xlsx]

(ooxml, embedded labels, table is [Mogelijkheid 1])

Group By Winkelwagen;