Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

simotrab
Contributor II

Load from different sources and merging the results

Hi Qlik Experts!

I have a question about load datas from difference sources.

Let's explain with an example:

first, I have this table from DataBase 1:

Table1:

LOAD

*

;

SQL SELECT

Person

FROM DataBase1;

The result is:

Person
p1
p2
p3
p4

Now, I should do the same thing with DataBase2:

Table2:

LOAD

*

;

SQL SELECT

Person

FROM DataBase2;

The result is:

Person
p1
p2
p5

I decide to use both the script in the same time (and I need one table), so the result is clearly this:

Table1_2:

LOAD

*

;

SQL SELECT

Person

FROM DataBase1;

Table1_2:

LOAD

*

;

SQL SELECT

Person

FROM DataBase1;

Person
p1
p2
p3
p4
p1
p2
p5

Now the question: could I do a " distinct" of the last table (and how)? In other words, could I reach (and how) this result?

Person
p1
p2
p3
p4
p5

Thanks a lot for your time!

1 Solution

Accepted Solutions
Not applicable

Re: Load from different sources and merging the results

you could look into the Exists function: The exists issue

(that article mentions the drawback with the Exists function - but also gives a usage example)

Otherwise, you could:

[Source_Data]:

LOAD *

FROM DB1;

CONCATENATE

LOAD *

FROM DB2;

[Result]:

LOAD DISTINCT

     *

RESIDENT Source_Data;

5 Replies
MVP
MVP

Re: Load from different sources and merging the results

Any reason you cant do the join in the database? Like:

SQL SELECT

     D1.Person

FROM DataBase1 D1

LEFT JOIN Database2 D2

     On D1.Person = D2.Person;

(assuming by database you mean a database table)

Not applicable

Re: Load from different sources and merging the results

you could look into the Exists function: The exists issue

(that article mentions the drawback with the Exists function - but also gives a usage example)

Otherwise, you could:

[Source_Data]:

LOAD *

FROM DB1;

CONCATENATE

LOAD *

FROM DB2;

[Result]:

LOAD DISTINCT

     *

RESIDENT Source_Data;

sfatoux72
Valued Contributor

Re: Load from different sources and merging the results

Try this,  :

  • Add distinct on each request if you could have duplicate on it
  • Add "Where not Exist(Person)" to load from the second request only new Person

Table1_2:

LOAD distinct

*

;

SQL SELECT

Person

FROM DataBase1;

Table1_2:

LOAD distinct

*

;

SQL SELECT

Person

FROM DataBase1

WHERE not exists(Person);

simotrab
Contributor II

Re: Load from different sources and merging the results

I'm sorry, but I cannot do this: I've not been clear about this (my fault).

simotrab
Contributor II

Re: Load from different sources and merging the results

Thanks, these are great topics.

Community Browser