Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
mwscott1
Creator
Creator

Trouble with joins I think

I have two tables (see below). With one entry on each the results are fine. However, when a second entry is added to table two the results are not what I want. The two tables are LEFT JOINED by REF Number...

Example 1

Table1Table2Results
REF NumberCandidate SubmittedREF NumberCandidate InterviewCandidate AppointedREF NumberCandidate SubmittedCandidate InterviewCandidate Appointed
R00011R00015R000115

Example 2

Table1Table2Results
REF NumberCandidate SubmittedREF NumberCandidate InterviewCandidate AppointedREF NumberCandidate SubmittedCandidate InterviewCandidate Appointed
R00011R00015R000115
R000110R0001110

I would like the results to be either of the two ways.

Results
REF NumberCandidate SubmittedCandidate InterviewCandidate Appointed
R00011510

or

Results
REF NumberCandidate SubmittedCandidate InterviewCandidate Appointed
R00011
R00015
R000110

Is this possible?

1 Solution

Accepted Solutions
MarcoWedel

Hi,

another solution could be:

QlikCommunity_Thread_192393_Pic1.JPG

REFERRALS:

LOAD Name,

    Address,

    Phone,

    City,

    State,

    [Zip Code],

    [P Name],

    [P Number],

    [P Email],

    [P Phone],

    Email,

    [REF Number],

    [Candidate Submitted]

FROM [https://community.qlik.com/servlet/JiveServlet/download/916959-197908/Referrals.xls] (biff, embedded labels, table is Sheet1$);

LEFT JOIN

TR:

LOAD [REF Number],

    [Candidate Interview]

FROM [https://community.qlik.com/servlet/JiveServlet/download/917024-197940/TR.xls] (biff, embedded labels, table is Sheet1$)

Where Len([Candidate Interview]);

LEFT JOIN

TR:

LOAD [REF Number],

    [Candidate Appointed]

FROM [https://community.qlik.com/servlet/JiveServlet/download/917024-197940/TR.xls] (biff, embedded labels, table is Sheet1$)

Where Len([Candidate Appointed]);

hope this helps

regards

Marco

View solution in original post

7 Replies
Anonymous
Not applicable

Hi

Take a look at the attached file.

Regards,

Gabriel

swuehl
MVP
MVP

Maybe like this:

Table1:

LOAD * INLINE [

    REF_Number, Candidate_Submitted

    R0001, 1

];

Concatenate (Table1)

LOAD REF_Number,

  If(isnum(Candidate_Interview),Candidate_Interview,NULL()) as Candidate_Interview, //only needed to create NULL for missing values

  if(IsNum(Candidate_Appointed),Candidate_Appointed,NULL()) as Candidate_Appointed //only needed to create NULL for missing values

INLINE [

    REF_Number, Candidate_Interview, Candidate_Appointed

    R0001,5,

    R0001,  ,10

];

NoConcatenate

Result:

Load

  REF_Number,

  Only(Candidate_Submitted) as Candidate_Submitted,

  Only(Candidate_Interview) as Candidate_Interview,

  Only(Candidate_Appointed) as Candidate_Appointed

Resident Table1

GROUP BY REF_Number;

DROP Tables Table1;

mwscott1
Creator
Creator
Author

OK I might have not have done a good job explaining what I am working with. Here is my script I have so far and some sample data attached...

REFERRALS:
LOAD Upper (F3) as "Name",
Upper (F4) as "Address",
Upper (F5) as "Phone",
Upper (F6) as "City",
Upper (F7) as "State",
Upper (F8) as "Zip",
Upper (F9) as "P Name",
Upper (F10) as "P Number",
Upper (F11) as "P Email",
Upper (F12) as "P Phone",
Upper (F13) as "Email",
Upper (F14) as "REF Number",
Upper (F15) as "Candidate Submitted"
FROM

(
biff, embedded labels, table is Sheet1$);

LEFT JOIN

TR:
LOAD F3 as "REF Number",
F4 as "Candidate Interview",
F5 as "Candidate Appointed"
FROM

FROM

(
biff, embedded labels, table is Sheet1$);

swuehl
MVP
MVP

Hm, these sample files don't show multiple "REF Number" values, so there shouldn't be a problem with the JOIN at all?

mwscott1
Creator
Creator
Author

I have attached a new TR file. the issue is the Candidate Submitted value of 1 is populated on the Referral Table the Candidate Interview value of 5 and Candidate Appointed value of 10  are populated on the TR table. If the Candidate Interview value of 5 and Candidate Appointed value of 10 are both added at the same time everything is fine, because there is a one to one entry on each table like Donald Duck in the Example below. However, if Candidate Interview value of 5 in populated on the TR table and then Candidate Appointed value of 10  are populated on the TR table there are 3 separate entries for the same REF Number.  In the results it combines two entries but not the third  which results in 2 lines and causes an extra 1 for Candidate Submitted. Example Jan Smith and John Doe

NameREF NumberCandidate SubmittedCandidate InterviewCandidate Appointed
DONALD DUCKR00041510
JAN SMITHR0002110
JAN SMITHR000215
JOHN DOER0001110
JOHN DOER000115
MICKEY MOUSER000315
swuehl
MVP
MVP

I am still assuming my previous approach should work, with your data, something along these lines:

REFERRALS:

LOAD Name,

     Address,

     Phone,

     City,

     State,

     [Zip Code],

     [P Name],

     [P Number],

     [P Email],

     [P Phone],

     Email,

     [REF Number],

     [Candidate Submitted]

FROM

[Referrals.xls]

(biff, embedded labels, table is Sheet1$);

LEFT JOIN

LOAD [REF Number],

     Only([Candidate Interview]) as [Candidate Interview],

     Only([Candidate Appointed]) as   [Candidate Appointed]

FROM

[TR (1).xls]

(biff, embedded labels, table is Sheet1$)

GROUP BY [REF Number];

MarcoWedel

Hi,

another solution could be:

QlikCommunity_Thread_192393_Pic1.JPG

REFERRALS:

LOAD Name,

    Address,

    Phone,

    City,

    State,

    [Zip Code],

    [P Name],

    [P Number],

    [P Email],

    [P Phone],

    Email,

    [REF Number],

    [Candidate Submitted]

FROM [https://community.qlik.com/servlet/JiveServlet/download/916959-197908/Referrals.xls] (biff, embedded labels, table is Sheet1$);

LEFT JOIN

TR:

LOAD [REF Number],

    [Candidate Interview]

FROM [https://community.qlik.com/servlet/JiveServlet/download/917024-197940/TR.xls] (biff, embedded labels, table is Sheet1$)

Where Len([Candidate Interview]);

LEFT JOIN

TR:

LOAD [REF Number],

    [Candidate Appointed]

FROM [https://community.qlik.com/servlet/JiveServlet/download/917024-197940/TR.xls] (biff, embedded labels, table is Sheet1$)

Where Len([Candidate Appointed]);

hope this helps

regards

Marco