Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dmac1971
Creator III
Creator III

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
dmac1971
Creator III
Creator III
Author

Apologies, not ignoring it, trying to go with the solution I understand better, that's all.

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Why don't you try something like:

LOAD

[your original load]

;

LEFT JOIN (Your Original Table)

LOAD

Line_ID,

RangeMin(Count(Line_ID), 1) as DuplicateFlag

RESIDENT

(Your Original Table)

GROUP BY Line_ID;

sunny_talwar

Not a problem.

Best,

Sunny

oknotsen
Master III
Master III

The solution is fooling around with a few Resident loads.

Lets assume the table with your original IF statement is called TableTMP.

DoubleTMP:

Mapping

Load Line_ID as DoubleID,

'Dub' as Flag

Resident TableTMP

where DupRec = 'Dub';

That makes a helper list with all the keys that are double.

Next, create your final table:

TableFinal:

NoConcatinate

Load

AllKindOfFieldsFromTableTMP,

applymap('DoubleTMP', Line_ID, 'NotDub') as DupRec

Resident TableTMP

;

Drop Table TableTMP;

I assume it can be done easier, but this should work.

May you live in interesting times!
Not applicable

Or yet another solution... count.

countduplicates:

MAPPING LOAD DISTINCT Line_ID,

          count(some field) As duplicates

RESIDENT table Group by Line_ID;

finaltable:

LOAD Line_ID,

Applymap('countduplicates',Line_ID,0)

RESIDENT table;

malini_qlikview
Creator II
Creator II

Try This

Load
Line_id,
If(Count(Line_id)>1,'Dup','No_Dup') AS DupRec
Resident Table
Group by Line_id;

sasiparupudi1
Master III
Master III

Please try

x:

LOAD *Inline [SalesID,SalesAmount

1,100

1,100

1,7

2,200

2,200

3,400

3,400

4,60

5,2000

6,900

];

y:

LOAD SalesID,SalesAmount,

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

Resident x

order by SalesID;

drop Table x;