Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Vlookup like function in loadscript

Hi,

I would like to add a number of fields to a table, without expanding the number of rows. Therefore I was thinking about a way to use a lookup function, which would give me the field values of another table corresponding with a field vale from my current table.

Table1:

FieldA
FieldB
FieldC
FieldPC
11abc002033
22def006034
23ght002035
24gyr007040

Table2:

ID
GB
WS
PC
101050020
202080020
3
90030
4
100050

Suppose I would like to join the values of of Table2 to Table1 based on PC. Although two rows have the same value for PC in Table2, I only want to add the first row (based on ID or load order).

I tried lookup(), left join and mapping load, but I have not made it work unfortunately.

1 Solution

Accepted Solutions
Not applicable
Author

Hi there, I am pretty sure you can accomplish this using maps or joins, the trick is to load only the usable rows from the second table, with a code similar to the following:

UsableIDs:

Load PC, min(ID) as MinID

from Table2.qvd (qvd)

group by PC;

Table2:

load ID, GB, WS, PC

from Table2.qvd (qvd)

where exists(MinID, ID);

Regards

View solution in original post

2 Replies
Not applicable
Author

Hi there, I am pretty sure you can accomplish this using maps or joins, the trick is to load only the usable rows from the second table, with a code similar to the following:

UsableIDs:

Load PC, min(ID) as MinID

from Table2.qvd (qvd)

group by PC;

Table2:

load ID, GB, WS, PC

from Table2.qvd (qvd)

where exists(MinID, ID);

Regards

Not applicable
Author

Thanks, this will do the trick!