Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Connecting 2 tables using different fields based on condition

Hi Guys,

I have 2 different tables in which I have information about 3 Plants. Unfortunately, each Plant uses a different logic for the connection between the 2 tables like below (the names are the field names):

   

PlantTable 1Table 2
AReference NoTracking ID
BSub Ref NoTracking ID
CSub Ref NoLoading ID

What I tried to do is to use 'if' statements in each load script to rename the fields to a common field based on the Plant condition. Something like below.

Table 1:

If(Plant='A', "Reference No" = TableKey,

If(Plant='B' or Plant='C', "Sub ref no" = TableKey))

Table 2:

If(Plant='A' or Plant='B', "Tracking ID" = TableKey,

If(Plant='C', "Loading ID" = TableKey))

I am not sure this is the right logic to get these things done. In addition, when trying to load the scripts, Qlik Sense gives the error that Field 'TableKey' not found.

Any help is appreciated! Thanks!

1 Solution

Accepted Solutions
marcus_sommer

I think the general logic is right but not the syntax and only one if will be needed. Try something like this:

Table 1:

If(Plant='A', "Reference No", "Sub ref no") as TableKey

Table 2:

If(Plant='C', "Loading ID", "Tracking ID") as TableKey

- Marcus

View solution in original post

1 Reply
marcus_sommer

I think the general logic is right but not the syntax and only one if will be needed. Try something like this:

Table 1:

If(Plant='A', "Reference No", "Sub ref no") as TableKey

Table 2:

If(Plant='C', "Loading ID", "Tracking ID") as TableKey

- Marcus