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

Bringing fields from 2 tables together into 1

Right, an easy one here i'm sure 🙂

I have data regarding the same records, held in 2 separate tables:

e.g.

Table1:

ID, A, B, C

Table 2:

ID, D, E

i want to bring them togther in my script to give me one table in qlikview, because there really is no reason for the data to be apart

so i want to create

Table 3:

ID, A, B, C, D. E

and drop Tables 1 & 2

Can someone tell me how to do this?

Thanks in advance

Matt

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Can this be simplified as:

First:
LOAD * INLINE [
ID, A, B, C
1, 5, 6, 7
2, 4, 3, 2
3, 1, 2, 3
4, 1, 2, 3
];

Second:
LOAD * INLINE [
ID, D, E
2, 9, 9
3, 4, 9
4, 6, 7
5, 1, 2
6, 0, 0
];

OUTER JOIN (First)
LOAD *
RESIDENT Second
;
DROP TABLE Second;

-Rob

View solution in original post

4 Replies
Not applicable
Author

You can use Join and Resident Loads. Here's a sample using Inline Loads for the original data:

First:
LOAD * INLINE [
ID, A, B, C
1, 5, 6, 7
2, 4, 3, 2
3, 1, 2, 3
4, 1, 2, 3
];
Second:
LOAD * INLINE [
ID, D, E
2, 9, 9
3, 4, 9
4, 6, 7
5, 1, 2
6, 0, 0
];
Mix:
LOAD ID As IDTemp, A As ATemp, B As BTemp, C As CTemp RESIDENT First;
JOIN LOAD ID As IDTemp, D As DTemp, E As ETemp RESIDENT Second;
DROP TABLE First;
DROP TABLE Second;
Data:
LOAD IDTemp As ID, ATemp As A, BTemp As B, CTemp As C, DTemp As D,
ETemp As E RESIDENT Mix;
DROP TABLE Mix;


I used an extra table in there to get back to the original file names. They key to making a new table (Mix) before dropping the previous table is to rename the fields. If the fields have the same name, you will not get a new table. There may be a better way to do it, but I usually want to get back to the field names of the original data, so I do the additional Load.

Not applicable
Author

Hi

You can do it with Add Load


First:
LOAD * INLINE [
ID, A, B, C
1, 5, 6, 7
2, 4, 3, 2
3, 1, 2, 3
4, 1, 2, 3
];

ADD LOAD * INLINE [
ID, D, E
2, 9, 9
3, 4, 9
4, 6, 7
5, 1, 2
6, 0, 0
];
[\code]

jj

</body>
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Can this be simplified as:

First:
LOAD * INLINE [
ID, A, B, C
1, 5, 6, 7
2, 4, 3, 2
3, 1, 2, 3
4, 1, 2, 3
];

Second:
LOAD * INLINE [
ID, D, E
2, 9, 9
3, 4, 9
4, 6, 7
5, 1, 2
6, 0, 0
];

OUTER JOIN (First)
LOAD *
RESIDENT Second
;
DROP TABLE Second;

-Rob

Not applicable
Author

Thank you all, will try out your suggestions tonight. Much appreciated.

Matt