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

Generic Keys

Hi Guys,

I have the following problem:

I have one table 'Sales' with a key field SalesId and a nother table left joining Sales called SalesResult with a field SalesResultId. However I would like to create an generic key out of SalesId&'|'&SalesResultId to create an unique identifier for all Sales.

Can someone give me an easy example how to do this?

Best

Harry

1 Solution

Accepted Solutions
its_anandrjs

Hi,

Please provide sample file this will more easy.

Ex:- For composite keys try this ways and let me know.

tmpTable:

Load

SalesId

From Sales;

Left Join(tmpTable)

Load

SalesResultId

From SalesResult;

Load

SalesId,

SalesResultId,

SalesId&'|'&SalesResultId as %Key

Resident tmpTable;

Drop Table tmpTable;

Regards

Anand

View solution in original post

5 Replies
saumyashah90
Specialist
Specialist

Just make a composite key

Load

SalesId&'|'&SalesResultId  as Comp_Key,

Xyz,


from abc;

Not applicable
Author

Thanks, Saumya! But this is not working for me because you have table SalesResult is joining table Sales. Therefore SalesResultId is unknown in Sales. I tried the following but got a synthetic key:

LEFT JOIN (Sales)

LOAD

SalesId&'|'&SalesResultId  as Comp_Key

RESIDENT Sales;

saumyashah90
Specialist
Specialist

Can you please send me your script.

I will edit and let you know the correct path.

its_anandrjs

Hi,

Please provide sample file this will more easy.

Ex:- For composite keys try this ways and let me know.

tmpTable:

Load

SalesId

From Sales;

Left Join(tmpTable)

Load

SalesResultId

From SalesResult;

Load

SalesId,

SalesResultId,

SalesId&'|'&SalesResultId as %Key

Resident tmpTable;

Drop Table tmpTable;

Regards

Anand

Not applicable
Author

Hi Harry,

I hope two columns SalesId,SalesResultId available in two tables. so at this point synthetic keys will generate.

If you are trying to avoid synthetic key, Please follow this

Sales -- keep it in two fields and generate a new column with concatenate

SalesResult -- common two fileds are commented and generate a new column with concatenate, its associated with previous one.

But two column names are same. then only associated.

Regards,

Sub2u.