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: 
harry_16
Contributor II
Contributor II

Script Help Needed: Create Unique Key by CONCATENATE of 4 columns from 2 different Table.

Hello Everyone,

 

I need help of writing script of creating unique key of 4 columns from 2 tables. please help me at earliest 

-----------************----------------------

LIB CONNECT TO 'DATABASE';

[TABLE 1] :

Load 

Column 1 as AA

Column 2 as BB

Column 3 as CC;

SQL SELECT "Column 1", "Column 2", "Column 3" FROM DATABASE Table;

 

[TABLE 2] :

Load 

Column X as XX

Column Y as YY

Column Z as ZZ;

SQL SELECT "Column X", "Column Y", "Column Z" FROM DATABASE Table;

 

Please help me what should I add in the script to create another table or add in any of the above table where I can make unique key as below.

 

CONCATENATE: Column Name: UNIQUEKEYADDR = AA&'-'&BB&'-'&XX'-'&YY

Please help me at earliest !!

Labels (2)
2 Replies
TauseefKhan
Creator III
Creator III

 

You can create a composite key by concatenating multiple fields that together.
Use the Autonumber function to generate a synthetic key in both table.

[TABLE 1] :

Load 
Autonumber(AA & BB & CC) as Key,

[TABLE 2] :
Autonumber(XX & YY & ZZ) as Key,


CONCATENATE ([TABLE 1])   // Concatenate TABLE 1 and TABLE 2
LOAD
Key,
XX,
YY,
ZZ
RESIDENT [TABLE 2];

****Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.****



harry_16
Contributor II
Contributor II
Author

Hello,
Thanks for the revert,

 

I want to create new table with Concatenate of columns of Table 1 and 2. I will still need the data of Table 1 and Table 2 individual for analysis. 

So just to clear I will need a column that is Concatenate of Column 1&Column 2& Column X& Column Y in new table.

 

please help me in this

 

Thanks