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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Joining tables

Here is a simplified example of what I am doing. Suppose you have these tables below. My goal is to join the two tables so that  Table 1 now has sales rep info. My issue is that table 2 (the ones with the sales rep) has some unique IDs appearing multiple times. However, I am not interested in precision, and I want the join to just bring in one match, and not all. For example. In table 1 there is a unique ID A, and if I simply join the two tables, I will get two matches for this ID  but I just want to pick the first one, John smith (or any of them really). What is the best way to do this? Don't want to use ApplyMap because I have a ton fields I want to bring in to table 1. Any suggestions? Thank you

 

   

Table 1
Unique IDDollar Amount
A98
B6
C

24

D 12
E73
F85
G57
H67
I65

   

Table 2
Unique IDSales rep
AJohn Smith
ABob
BJill
CSam
D Doug
EBecca
FJim
GJames
HIgor
IKate

Labels (1)
2 Replies
olivierrobin
Specialist III
Specialist III

hello

if you don't care of which sales rep you take

you may use a join like

left join(table1)

load Unique ID,maxstring(Sales Rep) as A_Sales_rep

from table2

group by Unique ID

vishsaggi
Champion III
Champion III

Just load your both tables as is and use below in your Table2 load script like:

Table2:

LOAD *

WHERE Flag = 1;

LOAD *, IF(UniqueID = Previous(UniqueID), 0, 1) AS Flag INLINE [

UniqueID, Salesrep

A, John Smith

A, Bob

B, Jill

C, Sam

D, Doug

E, Becca

F, Jim

G, James

H, Igor

I, Kate

];