<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic join two tables on multiple columns in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311714#M1197852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have 2 tables like mentioned below:&lt;/P&gt;&lt;P&gt;Tab1:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SubsGroupID,&lt;/P&gt;&lt;P&gt;PAYED_AMMOUNT,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;Select SubsGroupID, PAYED_AMMOUNT, .... from SUBSCRIBERS_BONUS;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tab2:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SubsGroupID,&lt;/P&gt;&lt;P&gt;PAYED_AMMOUNT,&lt;/P&gt;&lt;P&gt;ATTRIBUTED_BONUS&lt;/P&gt;&lt;P&gt;Select SubsGroupID, PAYED_AMMOUNT, ATTRIBUTED_BONUS from SUBS_BONUS_CONFIGURATION;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second table aims to keep things configurable, a kind of mapping between the subscriber group Id ( SubsGroupID) ,the payed ammount (PAYED_AMMOUNT) and the attributed bonus (ATTRIBUTED_BONUS).&lt;/P&gt;&lt;P&gt;When I load data I got wrong statistics, and when I checked on the net I found that it is due to Synthetic key. I found also that the problem appears only when we have more than one column to be joined (SubsGroupID,PAYED_AMMOUNT).&lt;/P&gt;&lt;P&gt;I should keep the table SUBS_BONUS_CONFIGURATION separated in order to update it.&lt;/P&gt;&lt;P&gt;Any body has an idea on how we can make join on multiple columns?&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Mar 2011 18:32:33 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-03-08T18:32:33Z</dc:date>
    <item>
      <title>join two tables on multiple columns</title>
      <link>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311714#M1197852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have 2 tables like mentioned below:&lt;/P&gt;&lt;P&gt;Tab1:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SubsGroupID,&lt;/P&gt;&lt;P&gt;PAYED_AMMOUNT,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;Select SubsGroupID, PAYED_AMMOUNT, .... from SUBSCRIBERS_BONUS;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tab2:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SubsGroupID,&lt;/P&gt;&lt;P&gt;PAYED_AMMOUNT,&lt;/P&gt;&lt;P&gt;ATTRIBUTED_BONUS&lt;/P&gt;&lt;P&gt;Select SubsGroupID, PAYED_AMMOUNT, ATTRIBUTED_BONUS from SUBS_BONUS_CONFIGURATION;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second table aims to keep things configurable, a kind of mapping between the subscriber group Id ( SubsGroupID) ,the payed ammount (PAYED_AMMOUNT) and the attributed bonus (ATTRIBUTED_BONUS).&lt;/P&gt;&lt;P&gt;When I load data I got wrong statistics, and when I checked on the net I found that it is due to Synthetic key. I found also that the problem appears only when we have more than one column to be joined (SubsGroupID,PAYED_AMMOUNT).&lt;/P&gt;&lt;P&gt;I should keep the table SUBS_BONUS_CONFIGURATION separated in order to update it.&lt;/P&gt;&lt;P&gt;Any body has an idea on how we can make join on multiple columns?&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 18:32:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311714#M1197852</guid>
      <dc:creator />
      <dc:date>2011-03-08T18:32:33Z</dc:date>
    </item>
    <item>
      <title>join two tables on multiple columns</title>
      <link>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311715#M1197853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Hi, you can make your own key, just create a link table with that key, try the following script :&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Tab1:&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Load&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Autonumber(SubsGroupID,PAYED_AMMOUNT) as key,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;PAYED_AMMOUNT,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;...&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;....&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Select SubsGroupID, PAYED_AMMOUNT, .... from SUBSCRIBERS_BONUS;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Tab2:&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Load&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Autonumber(SubsGroupID,PAYED_AMMOUNT) as key,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;PAYED_AMMOUNT,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;ATTRIBUTED_BONUS&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Select SubsGroupID, PAYED_AMMOUNT, ATTRIBUTED_BONUS from SUBS_BONUS_CONFIGURATION;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;T_key:&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Load&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;key,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;PAYED_AMMOUNT&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Resident Tab1;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Load&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;key,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;PAYED_AMMOUNT&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Resident Tab2;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Key:&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Noconcatenate Load distinct&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;key,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;PAYED_AMMOUNT&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Resident T_key;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Drop field SubsGroupID,PAYED_AMMOUNT from Tab1;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Drop field SubsGroupID,PAYED_AMMOUNT from Tab2;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Drop table T_key;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2011 18:07:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311715#M1197853</guid>
      <dc:creator />
      <dc:date>2011-03-09T18:07:46Z</dc:date>
    </item>
    <item>
      <title>join two tables on multiple columns</title>
      <link>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311716#M1197854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is always a best practice to resolve all synthetic keys in your script. Qlikview will create one for every combination, which can result in incorrect values. Another best practice is to include in the name of the key that you are creating an identifier of some sort so that you will always know that it is something that you've created versus from your data source. Another good idea is to use numbers or integers rather than text to speed up the connections.&lt;/P&gt;&lt;P&gt;If the tables have a 1 to 1 or 1 to many cardinality with no optionals on the 1 side, then you do not need to create an extra table. In this example, Table 1 is the one and Table 2 is the 0 to many in the cardinality:&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;STRONG&gt;Table1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;SQL Select&lt;/P&gt;&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;Payed_Amount,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;SubsGroupID + Payed_Amount AS '%Subscribers_Bonus_Key',&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;...&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;From SUBSCRIBERS_BONUS;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;STRONG&gt;Table2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;SQL Select&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;Attributed_Bonus,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;SubsGroupID + Payed_Amount AS '%Subscribers_Bonus_Key',&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;...&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;From SUBS_BONUS_CONFIGURATION;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;/P&gt;&lt;P&gt;This assumes that all combinations of Table2's key exists in Table1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the following example, the cardinality includes either an optional to many or many to many cardinality. This will require another table.&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;STRONG&gt;Table1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;SQL Select&lt;/P&gt;&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;Payed_Amount,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;SubsGroupID + Payed_Amount AS '%Subscribers_Bonus_Key',&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;...&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;From SUBSCRIBERS_BONUS;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;STRONG&gt;Table2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;SQL Select&lt;/P&gt;&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;Payed_Amount,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;Attributed_Bonus,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;SubsGroupID + Payed_Amount AS '%Subscribers_Bonus_Key',&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;...&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;From SUBS_BONUS_CONFIGURATION;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;STRONG&gt;LINK_Table:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;LOAD&lt;/P&gt;&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;Payed_Amount,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;%Subscribers_Bonus_Key&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;Resident Table1;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;Outer Join (LINK_Table)&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;LOAD&lt;/P&gt;&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;Payed_Amount,&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt 0.5in;"&gt;%Subscribers_Bonus_Key&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;Resident Table2;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;DROP Fields&lt;/P&gt;&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;"&gt;SubsGroupID,&lt;/P&gt;&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;"&gt;Payed_Amount&lt;/P&gt;&lt;P style="MARGIN:0in 0in 0pt;"&gt;From Table1,Table2;&lt;/P&gt;&lt;P&gt;This pulls in every combination and makes sure that it only joins correctly while resolving the synthetic key.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aline&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2011 19:05:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311716#M1197854</guid>
      <dc:creator />
      <dc:date>2011-03-09T19:05:53Z</dc:date>
    </item>
    <item>
      <title>join two tables on multiple columns</title>
      <link>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311717#M1197855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your replies, they are so helpful :))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2011 08:51:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/join-two-tables-on-multiple-columns/m-p/311717#M1197855</guid>
      <dc:creator />
      <dc:date>2011-03-10T08:51:01Z</dc:date>
    </item>
  </channel>
</rss>

