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

Show employees with more than one ID

Hi,

I only want to see the rows with employees with more than one records and each record.

 

ID, Employees

1,A

2,A

3,B

4,C

5,C

6,F

 

So my outcome I want is.

 

ID,Employees 

1,A

2,A

4,C

5,C

In expression or code.

Thanks

 

 

Labels (1)
1 Solution

Accepted Solutions
vchuprina
Specialist
Specialist

Hi,

You can add a flag in your script and then use it at the front end in your expressions.

Sum({<Flag = {1}>} Value)

DATA:
LOAD * Inline[
ID, Employees
1,A
2,A
3,B
4,C
5,C
6,F
];

LeftJoin(DATA)
LOAD
   Employees,

 '1' AS Flag
  Where IDPerEmployee > 1;
LOAD
   Count(ID) AS IDPerEmployee,
   Employees
Resident DATA
Group BY Employees;

Also, you can try the following expression

sum( {$ <Employees={"=count(ID)>1"} >} Value)

It's not a good idea to use if and aggr functions, because both of them are expensive from a performance point of view, so you should always try to avoid them.

Thanks,

VItalii

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").

View solution in original post

10 Replies
vchuprina
Specialist
Specialist

Hi,

You can make resident load from your table and count the number of ID for each employee.

After this in the preceding load filter data by condition IDPerEmployee > 1, and join (inner join) table to the original table.

Try script below:

DATA:
LOAD * Inline[
ID, Employees
1,A
2,A
3,B
4,C
5,C
6,F
];

Inner Join(DATA)
LOAD
   Employees
  Where IDPerEmployee > 1;
LOAD
   Count(ID) AS IDPerEmployee,
   Employees
Resident DATA
Group BY Employees
;

 

Regards,

Vitalii

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
D19PAL
Creator II
Creator II
Author

Thanks, any way to do in the frontend,

D19PAL
Creator II
Creator II
Author

Thinking about it, my data model is already too complicated as it is.

Can this be done in the front end?

 

chaorenzhu
Creator II
Creator II

if(aggr(nodistinct count(ID),Employees)>1,ID)

vchuprina
Specialist
Specialist

Hi,

You can add a flag in your script and then use it at the front end in your expressions.

Sum({<Flag = {1}>} Value)

DATA:
LOAD * Inline[
ID, Employees
1,A
2,A
3,B
4,C
5,C
6,F
];

LeftJoin(DATA)
LOAD
   Employees,

 '1' AS Flag
  Where IDPerEmployee > 1;
LOAD
   Count(ID) AS IDPerEmployee,
   Employees
Resident DATA
Group BY Employees;

Also, you can try the following expression

sum( {$ <Employees={"=count(ID)>1"} >} Value)

It's not a good idea to use if and aggr functions, because both of them are expensive from a performance point of view, so you should always try to avoid them.

Thanks,

VItalii

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
vinieme12
Champion III
Champion III

Just this is enough to see duplicates in front end

 

Dimension=

ID and Employee

Expression = 

if(count(Total  <Employee> Employee)>1,count(Total <Employee> Employee))

 

qlikCommunity.PNG

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
D19PAL
Creator II
Creator II
Author

It works with dummy data.

But with real data,  I've got multiple rows for ID so they are all showing over 1.

 

vchuprina
Specialist
Specialist

Try to use count(distinct ID) instead of count(ID)

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
tresesco
MVP
MVP

This?

Concat(DISTINCT {<Employees={"=Count(Employees)>1"}>}Employees)

tresesco_0-1650287697303.png