Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
camh99
Contributor
Contributor

Removing Duplicates in QlikView

Hi,

I was wondering if anyone might be able to help with an issue I'm having...

In essence, I've got a list of (almost entirely unique) IDs and details loaded in from a QVD, and I'd like to remove any IDs which appear more than once.

For example, I'd want the table below:

ID Position Salary
1 CEO 80000
2 Analyst 30000
2 Programmer 35000
3 HR 25000

 

to appear as:

ID Position Salary
1 CEO 80000
3 HR 25000

 

I'm sure there's a simple solution but I'm struggling to get QV to do what I want.

Any help is much appreciated!

Labels (1)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

You need to do this in two passes. One solution could be

// === Script 1
UniqueIDs:
Load * Where Count=1;
Load ID as UniqueID, Count(ID) as Count From <Source> Group By ID;

Data:
Load * From <Source> Where Exists(UniqueID,ID);

Drop Table UniqueIDs;
// === Script 2

Another Could be

// === Script 2
Data:
Load * From <Source>;

Inner Join (Data)
Load * Where Count=1;
Load ID, Count(ID) as Count From <Source> Group By ID;
// === Script 2

View solution in original post

2 Replies
hic
Former Employee
Former Employee

You need to do this in two passes. One solution could be

// === Script 1
UniqueIDs:
Load * Where Count=1;
Load ID as UniqueID, Count(ID) as Count From <Source> Group By ID;

Data:
Load * From <Source> Where Exists(UniqueID,ID);

Drop Table UniqueIDs;
// === Script 2

Another Could be

// === Script 2
Data:
Load * From <Source>;

Inner Join (Data)
Load * Where Count=1;
Load ID, Count(ID) as Count From <Source> Group By ID;
// === Script 2

camh99
Contributor
Contributor
Author

Perfect, thank you Henric!