Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

radupanciuc
New Contributor II

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

Re: Connecting 2 tables using different fields based on condition

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

1 Reply

Re: Connecting 2 tables using different fields based on condition

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

Community Browser