Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Lookup value from another table

Hi there,

I have what I think is a common question.

Simplified: I have two tables and want to pick/lookup/peek a value from TableA to TableB when scripting. I have a key. I have read about the functions but can't get which one to use and how to use them.

TableA


KeyValue
1b
2c
3d

I tried this...

TableB:

LOAD

     Field1 As MyKey,

     Lookup(Value, Key, MyKey, TableA) As ValueFromTableB

     Field3 ...

FROM MySource

I would like to accomplish a load where I can get the value from table B depending on which key I have in the current record from MySource.

Thanks in advance for your help!

Best,

Filip

1 Solution

Accepted Solutions
sunny_talwar

Try with single quotes around 1st, 2nd and 4th argument of Lookup function and original field name for MyKey (Field1)

TableB: 

LOAD Field1 As MyKey,

          LookUp('Value', 'Key', Field1, 'TableA') As ValueFromTableB 

          Field3 ... 

FROM MySource

There is an example given for lookup in help section: QlikView ‒ LookUp - script function

View solution in original post

4 Replies
sunny_talwar

Try with single quotes around 1st, 2nd and 4th argument of Lookup function and original field name for MyKey (Field1)

TableB: 

LOAD Field1 As MyKey,

          LookUp('Value', 'Key', Field1, 'TableA') As ValueFromTableB 

          Field3 ... 

FROM MySource

There is an example given for lookup in help section: QlikView ‒ LookUp - script function

vikasmahajan

use apply map instead of lookup

TEST1:

LOAD * INLINE

[Field

1

2

3 ];

MAP:

mapping LOAD * INLINE

[ Field,FiledVAlue

1,P1

2,P2

3,P3

];

TEST:

LOAD

ApplyMap('MAP',Field) as Field1

Resident TEST1;

DROP Table TEST1;

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
sunny_talwar

Applymap is a good idea, but the only problem could be if there are more than 2 column in the table we are looking the value from. So if there are only 2 columns in Table A (as provided by OP) then I would definitely vouch for ApplyMap, but if there are more than 2, ApplyMap can't be used without doing a Resident Load of the data into a table which only has two columns.