Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis A -B

I have a list of projects from the source A. And have the second list of projects from the source B. How do I list A-B or vice verse?

1 Solution

Accepted Solutions
Not applicable
Author

Is it in the script you want to take care of it? It might not be the most optimized way, but here is an example



Table1:
Load * inline [
Num, Label1
1,a
2,b
3,c];

Table2:
Load * inline [
Num, Label2
3,c
4,d
5,e];

Final:
Load Num, Label1 as Label, 'Table1' as Source
Resident Table1
Where NOT Exists(Label2,Label1);
concatenate
Load Num, Label1 as Label, 'Both' as Source
Resident Table1
Where Exists(Label2,Label1);
concatenate
Load Num, Label2 as Label, 'Table2' as Source
Resident Table2
Where Not Exists (Label1, Label2);

Drop table Table1;
Drop table Table2;



View solution in original post

6 Replies
Anonymous
Not applicable
Author

Make sure you have a keyfield in both sources with the same name then it will connects automaticly when you load.

If you share your loading script I glady have a look at it.

Not applicable
Author

Yea. I named the both fields same. Currently, I can distinguish the source of the projects, whether from list A or B. However, I don't know a way to have a chart (or a list etc.) listing only projects which are from source A but not in source B (A-B) or vice verse.

Not applicable
Author

In addition to naming the keyfield the same, for example project, you can added an addtional field to identify the project as A or B.

project,

project AS project A

project AS project B.

QlikView will not see these as keys so you can identifiy each project.

These can also be counted in expressions.

Hope this helps.

Don

Not applicable
Author

Is it in the script you want to take care of it? It might not be the most optimized way, but here is an example



Table1:
Load * inline [
Num, Label1
1,a
2,b
3,c];

Table2:
Load * inline [
Num, Label2
3,c
4,d
5,e];

Final:
Load Num, Label1 as Label, 'Table1' as Source
Resident Table1
Where NOT Exists(Label2,Label1);
concatenate
Load Num, Label1 as Label, 'Both' as Source
Resident Table1
Where Exists(Label2,Label1);
concatenate
Load Num, Label2 as Label, 'Table2' as Source
Resident Table2
Where Not Exists (Label1, Label2);

Drop table Table1;
Drop table Table2;



Not applicable
Author

Your solution works fine in order to only list few fields in the manner I want . However, I have more than 20 fields along with to operate on in both Table 1 and Table 2. So, in my case QV can't manage to load the data; waiting for minutes, then freezing.

Not applicable
Author

I have fixed my issue. I used your way to distingue the sources and to collect the data from the two tables into the final table with the related information and id only. Then I reloaded Table1 and Table2 with all the fields, and making a logical connection between the final table and these two full loaded tables through id fields by naming them same.