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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
laxmanqlik
Creator II
Creator II

How to use composite keys

Hi i have requirement that i need to use the composite keys to avoid the synthetic keys,

can anyone let me know how to create and use them,

my requirement is that i have 2 tables like below

Month                      ID                   details

Jan                         101                         x

Feb                         102                         y

March                      103                         z

Month                          ID                OP        

Jan                              101               a

Feb                              102               b

March                           103               c

Now i want these 2 tables to like below

Month                      ID                   details          OP

Jan                         101                         x               a

Feb                         102                         y               b

March                      103                         z               c

how can i get it with composite key.

if i use joins it looking like below

Month                      ID                   details          OP

Jan                         101                         x               -

Feb                         102                         y               -

March                      103                         z               -

Month                          ID                  details                  OP        

Jan                              101                   -                          a

Feb                              102                    -                         b

March                           103                    -                         c

please let me know the way

thanks in advance

2 Replies
tresesco
MVP
MVP

Try like:

Load

         Month,

         ID,

         details,

         Month&ID as CompKey

From Table1;

Join

Load

        Month&ID as CompKey,

        OP

From Table2;

Drop field CompKey;

its_anandrjs
Champion III
Champion III

You can do this way also

Simple Join

Tab1:
LOAD * INLINE [
Month, ID, details
Jan, 101, x
Feb, 102, y
March, 103, z
]
;

Join(Tab1)
LOAD * INLINE [
Month, ID, OP
Jan, 101, a
Feb, 102, b
March, 103, c
]
;

By Composite Keys

Tab1:
LOAD Month&ID as %Key,Month as Months, ID as User_ID, details;
LOAD * INLINE [
Month, ID, details
Jan, 101, x
Feb, 102, y
March, 103, z
]
;

Join(Tab1)

LOAD Month&ID as %Key, OP;
LOAD * INLINE [
Month, ID, OP
Jan, 101, a
Feb, 102, b
March, 103, c
]
;



Regards

Anand