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

Create a composite Key In qlik Compose.

Hello,

I came across a scenario to create a composite key in compose

For eg:     Key1 & '~' & Key2 AS Key1key2.

Is there a effective way in compose to create this kind of key?

#qlikcompose, #compositekey

Labels (2)
1 Solution

Accepted Solutions
Nanda_Ravindra
Support
Support

Hello @hsardar yes, you should be able to get the key you are asking for in Compose.

 

You can create a new attribute in the model for the composite key you want to build., and validate the model. Then in the DWH, you build an expression for this new composite key using CONCAT operation. You can then decide if you like to keep the original keys.

For example:

The table, 'order details' has 2 PKs, ProductID and OrderId. So in the model, the 'order details' table will look like this:

Nanda_Ravindra_0-1669227622437.png

 

1. Add the new attribute for the composite key in the model and remove the existing PKs from the 'order details table'. Your model will look like this:

Nanda_Ravindra_1-1669227861089.png

 

2. Validate the model

3. In the DWH mapping use this expression for the new composite key, OrderId_product_Id'

CONCAT(${OrderId}, '&', ${ProductID})

Like this:

Nanda_Ravindra_2-1669228126240.png

 

4. Validate the DWH and generate the instructions.

Hope this helps!

If you have questions or need help, please open a case with support and we should be able to walk you thru the steps.

Thanks,

Nanda

 

 

 

 

 

 

View solution in original post

2 Replies
Nanda_Ravindra
Support
Support

Hello @hsardar yes, you should be able to get the key you are asking for in Compose.

 

You can create a new attribute in the model for the composite key you want to build., and validate the model. Then in the DWH, you build an expression for this new composite key using CONCAT operation. You can then decide if you like to keep the original keys.

For example:

The table, 'order details' has 2 PKs, ProductID and OrderId. So in the model, the 'order details' table will look like this:

Nanda_Ravindra_0-1669227622437.png

 

1. Add the new attribute for the composite key in the model and remove the existing PKs from the 'order details table'. Your model will look like this:

Nanda_Ravindra_1-1669227861089.png

 

2. Validate the model

3. In the DWH mapping use this expression for the new composite key, OrderId_product_Id'

CONCAT(${OrderId}, '&', ${ProductID})

Like this:

Nanda_Ravindra_2-1669228126240.png

 

4. Validate the DWH and generate the instructions.

Hope this helps!

If you have questions or need help, please open a case with support and we should be able to walk you thru the steps.

Thanks,

Nanda