Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
erric3210
Creator
Creator

Not Exists/Exists Understanding - Why it is giving single result against multiple values

Hi Community,

I want to understand the behaviour of Not Exists/Exits function.

If some dimension has multiple values against it then why it is returning a single value against it.

After data reload, I'm getting single frequency against 'Lucy'.

Please see this below example. Lucy has 2 addresses - 'Madrid' & 'Paris'

but as per the A-Z sorting, it is returning 'Madrid' whichever comes first.

erric3210_0-1673389093825.png

Can someone please explain me this behaviour.

Regards,

Eric

Labels (3)
2 Solutions

Accepted Solutions
maxgro
MVP
MVP

Employees:

LOAD * inline [

Employee|ID|Salary

Bill|001|20000

John|002|30000

Steve|003|35000

(delimiter is '|');  

There are 3 values in the Employee field: Bill, John, Steve

 

Citizens:

Load * inline [

Employee|Address

Bill |New York -->  record not loaded because the field value Bill has already been loaded into Employee

Mary|London --> loaded

Steve |Chicago --> record not loaded because the field value Steve has already been loaded into Employee

Lucy |Madrid --> loaded

Lucy |Paris --> record not loaded because the field value Lucy has already been loaded into Employee

John |Miami  --> record not loaded because the field value John has already been loaded into Employee

] (delimiter is '|')

where not Exists (Employee);

There are 5 values in the Employee field  Bill, John, Steve, Mary, Lucy,

3 record in Employees, 2 record in Citizens

 

Drop table Employees;

There are 2 values in the Employee field after the drop table: Mary, Lucy,

0 record in Employees, 2 record in Citizens

View solution in original post

vinieme12
Champion III
Champion III

rename the field

Employees:
LOAD * inline [
Employee_E|ID|Salary
Bill|001|20000
John|002|30000
Steve|003|35000
] (delimiter is '|');

Citizens:
Load * inline [
Employee|Address
Bill|1000
Mary|2000
Steve|3000
Lucy|4000
Lucy|5000
John|6000
] (delimiter is '|') where not Exists (Employee_E,Employee);

Drop Tables Employees;

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

View solution in original post

4 Replies
maxgro
MVP
MVP

Employees:

LOAD * inline [

Employee|ID|Salary

Bill|001|20000

John|002|30000

Steve|003|35000

(delimiter is '|');  

There are 3 values in the Employee field: Bill, John, Steve

 

Citizens:

Load * inline [

Employee|Address

Bill |New York -->  record not loaded because the field value Bill has already been loaded into Employee

Mary|London --> loaded

Steve |Chicago --> record not loaded because the field value Steve has already been loaded into Employee

Lucy |Madrid --> loaded

Lucy |Paris --> record not loaded because the field value Lucy has already been loaded into Employee

John |Miami  --> record not loaded because the field value John has already been loaded into Employee

] (delimiter is '|')

where not Exists (Employee);

There are 5 values in the Employee field  Bill, John, Steve, Mary, Lucy,

3 record in Employees, 2 record in Citizens

 

Drop table Employees;

There are 2 values in the Employee field after the drop table: Mary, Lucy,

0 record in Employees, 2 record in Citizens

erric3210
Creator
Creator
Author

Hi @maxgro Thanks for the detailed explanation.

Suppose, instead of address, there is Amount. So, in that case we produce the wrong result.

How we do we tackle such scenarios

Example:

Employees:
LOAD * inline [
Employee|ID|Salary
Bill|001|20000
John|002|30000
Steve|003|35000
] (delimiter is '|');

Citizens:
Load * inline [
Employee|Address
Bill|1000
Mary|2000
Steve|3000
Lucy|4000
Lucy|5000
John|6000
] (delimiter is '|') where not Exists (Employee);

Drop Tables Employees;

 

Output coming:

Employee Address
Lucy 4000
Mary 2000

 

Desired Output:

Employee Address

Lucy 4000
Lucy 5000
Mary 2000

Regards,

Eric

vinieme12
Champion III
Champion III

rename the field

Employees:
LOAD * inline [
Employee_E|ID|Salary
Bill|001|20000
John|002|30000
Steve|003|35000
] (delimiter is '|');

Citizens:
Load * inline [
Employee|Address
Bill|1000
Mary|2000
Steve|3000
Lucy|4000
Lucy|5000
John|6000
] (delimiter is '|') where not Exists (Employee_E,Employee);

Drop Tables Employees;

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

@maxgro @vinieme12 Thanks for the clear explanation & providing the solution.

I still have some doubt related to it. For that, I'll post a new question.

Regards,
Eric