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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Self join using relationship mapping in Qlik

I would like to replicate the following join using Qlik syntax because one of my tables is SQL and the other is in Excel.  How can I do this?

SELECT inv.InvestmentCode

     ,tFloatLeg.MetaData1

     ,tFixedLeg.MetaData1

FROM [Investment] AS inv

INNER JOIN [Relationship] AS rel ON inv.InvestmentCode = rel.InvestmentCode

LEFT JOIN [Investment] AS tFloatLeg ON rel.FloatingLegCode = tFloatLeg.InvestmentCode

LEFT JOIN [Investment] AS tFixedLeg ON rel.FixedLegCode = tFixedLeg.InvestmentCode

Sql [Investment]:

InvestmentCodeMetaData1SomeMetaData
Investment123foobar
Investment456bazzerk
Investment789merprin
InvestmentABCzeegerk
InvestmentDEFremzeb
InvestmentGHIrakbra

Excel [Relationship]:

InvestmentCodeFloatingLegCodeFixedLegCode
Investment123Investment456Investment789
InvestmentABCInvestmentDEFInvestmentGHI
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi.  I solved my own problem:

[Invesment]:

LOAD

    InvestmentCode

    ,MetaData1

    ,SomeMetaData

SQL SELECT

    InvestmentCode

    ,MetaData1

    ,SomeMetaData

FROM dbo.InvestmentTable;

//relationship mapping

LEFT JOIN

LOAD

    InvestmentCode

    ,FloatingLegCode

    ,FixedLegCode

FROM [lib://my_excel_lib/investment_relationship_sheet.xlsx]

(ooxml, embedded labels, table is Sheet1);

//map the relationship to itself

LEFT JOIN

LOAD

    InvestmentCode AS FloatingLegCode

    ,MetaData1 AS SomeOtherMetaData

RESIDENT [Invesment];

View solution in original post

1 Reply
Anonymous
Not applicable
Author

Hi.  I solved my own problem:

[Invesment]:

LOAD

    InvestmentCode

    ,MetaData1

    ,SomeMetaData

SQL SELECT

    InvestmentCode

    ,MetaData1

    ,SomeMetaData

FROM dbo.InvestmentTable;

//relationship mapping

LEFT JOIN

LOAD

    InvestmentCode

    ,FloatingLegCode

    ,FixedLegCode

FROM [lib://my_excel_lib/investment_relationship_sheet.xlsx]

(ooxml, embedded labels, table is Sheet1);

//map the relationship to itself

LEFT JOIN

LOAD

    InvestmentCode AS FloatingLegCode

    ,MetaData1 AS SomeOtherMetaData

RESIDENT [Invesment];