Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Linked Tables - How to specify which table data come from?

Hi,

I have two tables linked together by Item ID. Table A has three Items while Table B has 5 items. There are 2 common items shared between table A and table B, 1 extra items from Table A and 3 from Table B. When I try to use Item ID as dimension it returns all 6 different Items but I need the 5 items from table B. Is there a way to specify from which table the data come? Thanks!

Table A        Table B

1                    1

2                    2

3                    5

                      6

                      7
Now Qlikview returns 1,2,3,5,6,7 but I only want 1,2,5,6,7 from Table B as my dimension.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

You can add an additional field, a flag that says what the data source is.  It could be:
'A' as Flag // for table A

'B' as Flag // for table B

View solution in original post

5 Replies
Anonymous
Not applicable
Author

You can add an additional field, a flag that says what the data source is.  It could be:
'A' as Flag // for table A

'B' as Flag // for table B

Not applicable
Author

Hi Michael,

thanks for replying. I don't really understand it though. Do you mean add additional field in my data file?? COuld you please explain in a little more detail on how I should do it or give me a sample file? Thank you~

Anonymous
Not applicable
Author

Shuyu,

I assume that you create one table out of two:

Data:

LOAD

ID

FROM TableA;

CONCATENATE

LOAD

ID

FROM TableB;

In this case, I suggest to add a flag field:

Data:

LOAD

ID,

'A' as Flag

FROM TableA;

CONCATENATE

LOAD

ID,

'B' as Flag

FROM TableB;

Now, if you select Flag='B', you get the data from the table B only.

If you do not concatenate, but just link the tables by ID, it is essentially the same except the flag fields must have different names.  Or you duplicate ID if you prefer:

Table1:

LOAD

ID,

...,

ID as ID_A

FROM TableA;

Table2:

LOAD

ID,

...,

ID as ID_B

FROM TableB;

Select all values in the field ID_B to get IDs from the table B.

Not applicable
Author

Hi Michael,

Thank you for the explanation!!

For the first approach, what is the syntax of adding flag field?? Adding one extra line of ( 'A' as Flag) doesn't seem to work?

For the second approach, if I name ID as different names ID_A and ID_B, will the two tables still link together by ID?

Thank you!

Anonymous
Not applicable
Author

The first approach is for situation where you concatenate both tables in one.  If you do it, and it doesn't work - upload an example so I can see it.  The syntax is the one in bold.

For the second approach - I do not say to rename ID,  I say to create duplicates of the ID.  That is, you have field ID in both tables for linking, field ID_A only in table 1, and field ID_B only in table 2.