Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
biob_stein
Contributor

Multiple lookup

Hi Community,

how can i do a multiple lookup?

I tried following without luck :

Lookup ('ComponentName', 'ProductID', Lookup ('ProductCategory', 'ProductID', ProductID, 'ProductTable') , 'ComponentTable')

Tags (2)
7 Replies
anbu1984
Honored Contributor III

Re: Multiple lookup

Can you show script and sample data.

biob_stein
Contributor

Re: Multiple lookup

Hi,

cant show sample data, script is just loading three tables and making an lookup at one of this tables (Product).

With the result of this lookup i want to lookup at the second table (Component).

Additionaly when doing a simple lookup i will get erverytime only one result.

But there are also use cases where more than one value can be looked up, how to achive this?

deepaktibhe
Valued Contributor

Re: Multiple lookup

try applymap function, experts please correct me if I am wrong.

Thanks

biob_stein
Contributor

Re: Multiple lookup

Hey Deepak,

this is not really helping me, i need just an lookup where the third parameter is an result of an previous lookup.

anbu1984
Honored Contributor III

Re: Multiple lookup

Your example doesn't look correct. Your inner lookup retrieves ProductCategory based on ProductID and the same is used against ProductID in outer lookup?

biob_stein
Contributor

Re: Multiple lookup

Yes it should be like this,


Lookup ('ComponentName', 'ComponentID', Lookup ('ComponentID', 'ProductID', ProductID, 'ProductTable'), 'ComponentTable')


but that still not change the fact that it seems that nested lookups are not possible in qlikview


flipside
Valued Contributor II

Re: Multiple lookup

I don't think that is the case, the example below seems to work.

ProductTable:

Load * inline [
ProductID, ProductCategory, ComponentID
1, A, 123
2, B, 123
3, A, 333
4, C, 541
5, B, 221
]
;

ComponentTable:
Load * inline [
ComponentID,ComponentName
123, ABC
333, DEF
541, GHI
221, JKL
]
;

Data:
Load
Rowno() as ID,
Lookup('ComponentID','ProductID',rowno(),'ProductTable') as ID_output_lkp1,
Lookup('ComponentName','ComponentID',Lookup('ComponentID','ProductID',rowno(),'ProductTable'),'ComponentTable') as ID_output_lkp2
autogenerate 5;

I am sure there is a better way of doing what you want unless you can give more info to suggest otherwise. ApplyMap or left joins should do what you need.

flipside

Community Browser