Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Linking two tables with variable length key?

I have two tables, one has a full Identification number and the second has a partial number - the partial could be length of 2, 3, 4, etc

Basically - I want to compare if Left(Indentification_Num,len(Partial_Num)) = Partial_Num

First:

Indentification_num

other fields

Second:

Partial_num

other fields

Is there a way to do this in the load script?

thanks

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Here's one possible solution. See attached example.

FOR i = 0 to NoOfRows('Table2')-1

LET vPartial = peek('Partial_num', $(i), 'Table2');

LET vLink = peek('%Link', $(i), 'Table2');

Table1_Matches:

LOAD

          Indentification_num

          ,$(vLink) as %Link

RESIDENT Table1

WHERE Indentification_num LIKE '$(vPartial)*'

;

NEXT i

-Rob

View solution in original post

6 Replies
MayilVahanan

HI

Is there any field common in both table?

if so, then join with that. After that, compare identification number and partial number . Can you elaborate your table structure?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

No other common fields, that is the problem I am having.

MayilVahanan

HI

Create the key for both the tables and join based on that key. Then compare it.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Maybe I am not being really clear.  Table1 are all 10 digits.  Table 2 can be between 2-10 digits.  So the Bold in table one are the ones that would matchup.

Table1

Indentification_num

1234567891

1237346731

1453626723

1231461234

2345555555

2366262662

2388888888

3452626127

3453777777

Table2

Partial_num

123

23

3453

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Here's one possible solution. See attached example.

FOR i = 0 to NoOfRows('Table2')-1

LET vPartial = peek('Partial_num', $(i), 'Table2');

LET vLink = peek('%Link', $(i), 'Table2');

Table1_Matches:

LOAD

          Indentification_num

          ,$(vLink) as %Link

RESIDENT Table1

WHERE Indentification_num LIKE '$(vPartial)*'

;

NEXT i

-Rob

Not applicable
Author

Thanks for the responses.  Rob that looks like it will work for me.  I appreciate it!