Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
laxmanqlik
Contributor 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
MVP
MVP

Re: How to use composite keys

Try like:

Load

         Month,

         ID,

         details,

         Month&ID as CompKey

From Table1;

Join

Load

        Month&ID as CompKey,

        OP

From Table2;

Drop field CompKey;

Re: How to use composite keys

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

Community Browser