Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have to join the tables based on the design below. I have three tables.
Table 1, Table 2 and Table3 with the column mentioned below.
Table 1 - Column A (PK)
Table 2 - Column B (FK)
From Table 1, for every value in column A, I need corresponding value in Table 2(Column B).
But When I filter with one more column (column X), I need to pick corresponding value in Table 3 (column Y)
and then I need to pick corresponding value in Table 2 (column B).
Table 1:
A | X |
Table 2:
Y | B |
Table 3:
X | Y |
How do I join these table while loading the data? Can someone help me?
Thanks in advance
Try the script below. Change the ...."from [ ]" to include the source path of your data tables. You can change the join's to be left, inner, outer, etc or specify them as keeps instead of joins depending on your requirements.
//Script
TABLE1:
LOAD
A, X
FROM [TABLE1];
LEFT JOIN (TABLE1)
TABLE2:
LOAD
Y, B as A, B
FROM [TABLE2];
LEFT JOIN (TABLE1)
TABLE3:
LOAD
X,Y
FROM [TABLE3];
Hi,
Thanks for your response.
so, you basically want to make a Left Join of two table with the Table 1.
But, what is "B as A" ? Why do we need to change the field B as A?
A in Table 1 is not same as B in Table 2.
I need to traverse in this way.
A (Table 1) -> X (Table 3) -> Y (Table 3) -> B (Table 2)
The use of "as" in the load script is renaming the field. Two fields named the same is seen as the same in qlikview, so this is to distinguish.
I misunderstood the relationships of the fields between tables in the previous post.
The script below would be an option to associate the data.
//script
T1:
LOAD
A AS A1,
B AS B1,
A AS X3
FROM [source]
;
LEFT JOIN (T1)
T3:
LOAD
X AS X3,
Y AS Y3,
Y AS B2
FROM [source]
;
LEFT JOIN (T1)
T2:
LOAD
B AS B2,
Y AS Y2
FROM [source]
;