Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
dmac1971
Contributor II

Flagging Duplicates

I can easily enough find what records are duplicated :

if (peek('Line_ID',-1) = Line_ID ,'Dup','NoDup') as DupRec

But this will only mark the 2nd record, I need to mark the first one as well, ie mark them both as duplicate?


16 Replies

Re: Flagging Duplicates

So, if I am thinking this correctly, I think the only places that would be left would be the places where you have 1st duplicates cause everything else will either have Dup or NoDup. Can you do something like this:

YourTable:

LOAD If(Len(Trim(DupRec)) = 0, 'Dup', DupRec) as DupRec;

LOAD if (peek('Line_ID',-1) = Line_ID ,'Dup','NoDup') as DupRec

             ....

From/Resident xyz

Order by Line_ID;

Let me know if it doesn't work.

Best,

Sunny

Not applicable

Re: Flagging Duplicates

Hi Dermot,

Try like this....

if(Peek('Line_ID')=Line_ID,0,1) as Flag

from resident table

order by Line_ID

dmac1971
Contributor II

Re: Flagging Duplicates

Still gives the same result, only in reverse.

datanibbler
Esteemed Contributor

Re: Flagging Duplicates

Hi Dermot,

I think, since QlikView loads the table one record at a time, from the top down, there's no way to do this in one go - you'll have to do one RESIDENT LOAD in reverse sorting order and do the same as the first time round.

Best regards,

DataNibbler

Re: Flagging Duplicates

Did you take a shot at what I suggested? Just curious

Not applicable

Re: Flagging Duplicates

Try Like this....

Order by Line_ID DEC

Not applicable

Re: Flagging Duplicates

Could you use Peek('Line-ID', RowNo()+1,'table') to check for the next to get a flag on the first one too.

dmac1971
Contributor II

Re: Flagging Duplicates

OK Trying This :

If (Peek('Line_ID',-1) = Line_ID,'Dup', If(Peek('Line-ID', RowNo()+1,'Orders') = Line_ID,'Dup','NoDup')) as DupRec

Doesn't work either....

Re: Flagging Duplicates

I guess for some reason you hate my suggestion. I was just trying to help.

I hope you get what you are looking for.

Best,

Sunny

Community Browser