Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
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
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~
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.
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!
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.