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

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Join tables with condition

Hi!

I want to join the next tables:

Table1:

YEART1_IDIDDENOM
201211111Denomination1
201212222Denomination1
201221111Denomination2
201223333Denomination2

Table2:

YEART2_IDID
201211111
201212222
201221111
201231111
201233333
201234444

The target that I have to reach:

YEART2_IDIDDENOM
201211111Denomination1
201212222Denomination1
201221111
201231111Denomination2
201233333Denomination2
201234444

So I have to check that each T2_ID have all ID from Table1, to take DENOM value. For example, T2_ID = 2, has no DENOM value because only with ID = 1111 is not possible. It would be necessary another row with ID = 2222 or ID = 3333.


However, T2_ID = 3, with ID in (1111, 3333), take Denomination2 value although it's not available for all rows (ID = 4444).


How can I do that in the script?


Thanks!

Labels (1)
9 Replies
salto
Specialist II
Specialist II

Hi,

you say "For example, T2_ID = 2, has no DENOM value because only with ID = 1111 is not possible." - T2_ID =2 has an ID = 1111, and a YEAR=2012, so it has Denom1 and Denom2 in Table1.

I'm afraid I have not understood your requirements...

Not applicable
Author

Table 1 works like an group with fields YEAR-T1_ID. So, T2_ID = 1 matchs in group 1 (T1_ID = 1).

However, T2_ID = 2 don't match with any group because it needs ID = 2222, to get Denomination1, or ID = 3333, to get Denomination2.

I hope I have explained better.

Thanks!

Not applicable
Author

In addition, I need to do this because I want that when user choose "Denomination1", it only appears T2_ID = 1.

Without this join, if user choose ID values 1111 and 2222, it will appear all T2_ID values and I don't want that.

Not applicable
Author

I have looked for in forums but I have not found a solution for this issue. On the other hand, there isn't an easy way to select dimension values and works like an AND clause. I have seen in the web a similar example to change the selection mode. This example solves the problem with the selection mode when you select different dimensions, but I want to change the mode when I select an only dimension.

When I select, for example, two values in a dimension I want the AND mode not the OR mode.

Not applicable
Author

Hi Qlikviewers!

I keep thinking about how to solve this problem.


Do you think it's better change the sql views that I have now?


Thanks!

salto
Specialist II
Specialist II

Hello,

Just to check if I hve understood correctly: all values YEAR and ID from table2 need to be in Table1 ?

Not applicable
Author

No, it's not necessary.

For example, ID = 4444 is not in Table1.

salto
Specialist II
Specialist II

Hello again,

I am sorry but I do not understand the rules that make a record in the resultant table. Could you please explain where does every record in the resultant table come from?

Thanks.

Not applicable
Author

Hi again:

Ok, I write the conditions of the example (the colors show the groups):

  • Table1 has two groups (YEAR-T1_ID). Each group has the same DENOM value.
  • Table2 has three groups (YEAR-T2_ID)
  • Target table and Table2 must have the same number of records.
  • For the first group of Table2, I have to check that ID values (1111, 2222) match with a group of Table1. In this case, it gets Denomination1.
  • For the second group of Table2, I have to check that ID value (1111) math with a group of Table1 but it's not possible because there isn't a group with only 1111.
  • For the third group of Table2, I have to check that ID values (1111, 3333, 4444) match with a group of Table1. In this case, ID values 1111 and 3333 math with T1_ID = 1, so it gets Denomination2 (only for ID values 1111 and 3333).

Thanks!