Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

joining 2 fields from different tables in load script

i want to create a unique key in a table so that qlikview automatically joins the tables.

Therefore how do i join 2 fields from 2 different tables in the load script:

MY SCRIPT LOOKS LIKE THE FOLLOWING

---------

TABLE 1
LOAD
FIELD 1,
FIELD 2,
FIELD 3,
FROM data\Table 1.qvd (qvd);

TABLE 2
LOAD
FIELD A,
FIELD B,
FIELD C,
FROM data\Table 2.qvd (qvd);

TABLE 3
LOAD
Key,
[Account Type]
[Transaction Type]
FROM [data\Lookup Table 3.xls];

------------

What i want to do is create a new field in Table 2 called 'Key' and this should be made from a concatenation of Table 1.Field 1 + Table 2.Field B

Regards

1 Solution

Accepted Solutions
syed_muzammil
Partner - Creator II
Partner - Creator II

Hi,

This is just an example for u . You can replace the Temp1 and Temp2 tablea with your Table1 and Table2. Temp3 is the temporary table. Sorry for the confusion. Heres the code as per your requirement.

There is jus one temporary table Main_temp .


Transactions:
LOAD TRX_ID AS [Transaction ID],
[Transaction Type],
ACC_ID,
FROM
data\TRANSACTIONS.qvd
(qvd);


Accounts:
LOAD
ACC_ID,
LEDTYP_ID,
FROM
data\ACCOUNTS.qvd
(qvd);


Main_Temp:
load
ACC_ID,
[Transaction Type] as TT,
Resident Transactions;

Left Join(Main_Temp)
load ACC_ID,
LEDTYP_ID as LTI
Resident Accounts;

Left Join (Accounts)
Load
ACC_ID,
TT&'.'&LTI as Key
Resident Main_Temp;
Drop table Main_Temp;

View solution in original post

13 Replies
Not applicable
Author

What is a relationship between Table1 and Table2. Or do you want to make cartesian?

Not applicable
Author

i guess cartesian join, i havent defined any joins between table 1 and table 2.

Not applicable
Author

any update on this thread??????

syed_muzammil
Partner - Creator II
Partner - Creator II

Hi,

TABLE 2
LOAD
FIELD A,
FIELD B,
FIELD C,

FIELD 1& '.' & FIELD B


FROM data\Table 2.qd (qvd);
RESIDENT TABLE 1;

The '.' in

FIELD 1& '.' & FIELD B is a delimiter. You can remove it if you want to.

Not applicable
Author

Normal 0 false false false MicrosoftInternetExplorer4

Hi, this doesnt seem to work as i get the 'Field not found - <Transaction Type> ' error.

Heres the script im using which shows tables 1 and 2. The key field im trying to create is [Transaction Type]& '.' & LEDTYP_ID

--------------------------

Directory;

Transactions:

LOAD TRX_ID AS [Transaction ID],

[Transaction Type],

ACC_ID,

FROM

data\TRANSACTIONS.qvd

(qvd);

LOAD

ACC_ID,

LEDTYP_ID,

[Transaction Type]& '.' & LEDTYP_ID

FROM

data\ACCOUNTS.qvd

(qvd);

RESIDENT TRANSACTIONS;

----------------------------

What do i have to do to get this script to work and make the join field?



syed_muzammil
Partner - Creator II
Partner - Creator II

hey,

Try this . You have to give an Alias Name to the new feild created. [Transaction Type]& '.' & LEDTYP_ID AS KEY

Transactions:

LOAD TRX_ID AS [Transaction ID],

[Transaction Type],

ACC_ID,

FROM

data\TRANSACTIONS.qvd

(qvd);

LOAD

ACC_ID,

LEDTYP_ID,

[Transaction Type]& '.' & LEDTYP_ID AS KEY

FROM

data\ACCOUNTS.qvd

(qvd);

RESIDENT TRANSACTIONS;

Not applicable
Author

The following errors appear

Field not found - <Transaction Type>

also

Unknown statement
RESIDENT Transactions

Not applicable
Author

Any help on this would be great?

Not applicable
Author

does anyone have any advise on this?

regards

jason