<?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 Re: Data model with combined Key (issue) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Data-model-with-combined-Key-issue/m-p/912634#M316700</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue was resolved. I need to split the KEY_2 column from the bridge table and keep in the TABLE_COMBINED.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the part of the query that will have to be changes and it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// combine TABLE_A and TABLE_B to one table&lt;/P&gt;&lt;P&gt;TABLE_BRIDGE:&lt;/P&gt;&lt;P&gt;LOAD Distinct&lt;/P&gt;&lt;P&gt;COMBINED_KEY&lt;/P&gt;&lt;P&gt;,KEY_1&lt;/P&gt;&lt;P&gt;//,KEY_2&lt;/P&gt;&lt;P&gt;,TYPE&lt;/P&gt;&lt;P&gt;Resident TABLE_A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Concatenate(TABLE_BRIDGE)&lt;/P&gt;&lt;P&gt;LOAD Distinct&lt;/P&gt;&lt;P&gt;COMBINED_KEY&lt;/P&gt;&lt;P&gt;,KEY_1&lt;/P&gt;&lt;P&gt;//,KEY_2&lt;/P&gt;&lt;P&gt;,TYPE&lt;/P&gt;&lt;P&gt;Resident TABLE_B;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Fields KEY_1,TYPE From TABLE_A;&lt;/P&gt;&lt;P&gt;DROP Fields KEY_1,TYPE From TABLE_B;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Join(TABLE_A)&lt;/P&gt;&lt;P&gt;LOAD * Resident TABLE_B;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table TABLE_B;&lt;/P&gt;&lt;P&gt;RENAME Table TABLE_A to TABLE_COMBINED;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS - not that i intended to answer myself, but it might help other peoples' time in answering the questions that needs real attention &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Aug 2015 15:35:24 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-08-06T15:35:24Z</dc:date>
    <item>
      <title>Data model with combined Key (issue)</title>
      <link>https://community.qlik.com/t5/QlikView/Data-model-with-combined-Key-issue/m-p/912633#M316699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Facing a typical issue with a data model design - I am attaching the qvw file with an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having two tables&lt;/P&gt;&lt;P&gt;TABLE A -&amp;nbsp; columns &lt;SPAN style="font-size: 13.3333330154419px;"&gt;DT_1,DT_2, KEY_1&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt; will be used to match identical record in TABLE B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;&lt;EM&gt;DT_1,DT_2, KEY_1, KEY_2, AMOUNT_1 , TYPE&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;&lt;EM&gt;01/01/2014,01/30/2014, 1,3, 100, FROM_A&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;TABLE B -&amp;nbsp; the columns DT_1&amp;nbsp; and &lt;SPAN style="font-size: 13.3333330154419px;"&gt;KEY_1 will be used to relate a record in TABLE A, logic if&amp;nbsp; (TABLE_B.DT_1 is between TABLE_A.DT_1 and DT_2 and TABLE_B.KEY_1 = TABLE_A.KEY_1)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000;"&gt;&lt;EM&gt;&lt;STRONG&gt;DT_1,KEY_1, KEY_2, AMOUNT_2 , TYPE&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000;"&gt;&lt;EM&gt;&lt;STRONG&gt;01/02/2014, 1, 1, 25, FROM_B&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I created a combined key based on&amp;nbsp; &lt;SPAN style="; color: #800000;"&gt;&lt;STRONG&gt;num(DT_1) &amp;amp; '-' &amp;amp; KEY_1 as COMBINED_KEY,&lt;/STRONG&gt;&lt;/SPAN&gt; and used the above logic to map to the right records from TABLE B to TABLE A.. then generated a bridge table to move the common keys and finally merged TABLE A and TABLE B to single table. Till here straight forward. The reason to combine and create a COMBINED_KEY is to satisfy the following cases, but it was missing few scenarios which supposed to behave differently which i will explain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it will be easy if I try to follow the steps and values as per the attached qvw file (please open the qvw file now) Also attached some images and other charts to the file,&amp;nbsp; just to map to the input values with results in place, but the goal is on the top 3 text boxes with totals.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;CASE 1&lt;/STRONG&gt;&lt;/SPAN&gt;: &lt;SPAN style="font-size: 13.3333330154419px;"&gt;Clear all sections,&lt;/SPAN&gt;Select &lt;SPAN style="font-size: 13.3333330154419px;"&gt;from &lt;/SPAN&gt;Type list box - select a value 'FROM A'&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Behaviour :&lt;/STRONG&gt;&lt;/SPAN&gt; Should combine all totals from TABLE A&amp;nbsp; based on COMBINED_KEY - which in this case (&lt;SPAN style="font-size: 13.3333330154419px;"&gt;41640-1), so &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Table A total - 100, and since the matching combined key (i.e. 41640-1) exists in TABLE B for 2 records - with total - 75&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Expected:&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 13.3333330154419px;"&gt; TABLE A= 100, TABLE B =75, TOTAL (A+B) = 175,&lt;SPAN style="font-size: 13.3333330154419px;"&gt;So far good.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;CASE 2&lt;/STRONG&gt;&lt;/SPAN&gt;: &lt;SPAN style="font-size: 13.3333330154419px;"&gt;Clear all sections,&lt;/SPAN&gt;Select &lt;SPAN style="font-size: 13.3333330154419px;"&gt;from &lt;/SPAN&gt;Type list box - select a value 'FROM B'&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Behaviour :&lt;/STRONG&gt;&lt;/SPAN&gt; Should combine all totals from TABLE B based on COMBINED_KEY - which in this case -&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the matching combined keyare 41640-1 &amp;amp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;41730-2 So the totals are sum of affected keys &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Expected:&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 13.3333330154419px;"&gt; TABLE A= 100, TABLE B =250, TOTAL (A+B) = 350. So far good&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;CASE 3&lt;/STRONG&gt;&lt;/SPAN&gt;: Clear all sections, Select from &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;KEY_2&lt;/STRONG&gt;&lt;/SPAN&gt; list box value '4' (please note, not from KEY 1)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;&lt;SPAN style="; color: #ff0000; font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;Behaviour&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/STRONG&gt;&lt;/SPAN&gt; Key2 value 4 is only in TABLE B with a row level value 100, but the total is coming as 175, the reason is the issue in the design. i.e. when KEY2 value 4 is selected, the &lt;SPAN style="font-size: 13.3333330154419px;"&gt;COMBINED_KEY key for that row was (41730-2) and since the same key exists for the KEY2 value = 3 in TABLE B sum is combined for the both which is 100+ 75, &lt;STRONG&gt;&lt;SPAN style="color: #ff0000;"&gt;But I am looking to get only 100 in this case.&lt;/SPAN&gt; &lt;/STRONG&gt;In other words I wanted to combine when the same &lt;SPAN style="font-size: 13.3333330154419px;"&gt;COMBINED_KEY exits for TABLE A not within the same table (i.e. TABLE B in this case).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #ff0000; font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;Expected&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/STRONG&gt;&lt;/SPAN&gt; Not as expected. should result in TABLE A= 0, TABLE B =100, TOTAL (A+B) = 100.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;CASE 4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;:&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Clear all sections, Select from KEY_2 list box value '3'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="color: #ff0000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #ff0000; font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;Expected :&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt; Key2 value = 3 exits in both TABLE A and TABLE B, so as per case 2 explanation,takes &lt;SPAN style="font-size: 13.3333330154419px;"&gt;COMBINED_KEY =&amp;nbsp; (41640-1 and&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;41730-2) so the result was all the totals for both keys. But that is not the expected behaviour, should result considering the KEY2 value 3 record in TABLE A and TABLE B (i..e 100 from table A and 75 from TABLE B).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 13.3333330154419px; color: #0000ff;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #ff0000; font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;Expected&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt; Not as expected. should result in TABLE A= 100, TABLE B =75, TOTAL (A+B) = 175.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I appreciate the community for your contribution in helping others.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2015 01:19:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-model-with-combined-Key-issue/m-p/912633#M316699</guid>
      <dc:creator />
      <dc:date>2015-08-06T01:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Data model with combined Key (issue)</title>
      <link>https://community.qlik.com/t5/QlikView/Data-model-with-combined-Key-issue/m-p/912634#M316700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue was resolved. I need to split the KEY_2 column from the bridge table and keep in the TABLE_COMBINED.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the part of the query that will have to be changes and it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// combine TABLE_A and TABLE_B to one table&lt;/P&gt;&lt;P&gt;TABLE_BRIDGE:&lt;/P&gt;&lt;P&gt;LOAD Distinct&lt;/P&gt;&lt;P&gt;COMBINED_KEY&lt;/P&gt;&lt;P&gt;,KEY_1&lt;/P&gt;&lt;P&gt;//,KEY_2&lt;/P&gt;&lt;P&gt;,TYPE&lt;/P&gt;&lt;P&gt;Resident TABLE_A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Concatenate(TABLE_BRIDGE)&lt;/P&gt;&lt;P&gt;LOAD Distinct&lt;/P&gt;&lt;P&gt;COMBINED_KEY&lt;/P&gt;&lt;P&gt;,KEY_1&lt;/P&gt;&lt;P&gt;//,KEY_2&lt;/P&gt;&lt;P&gt;,TYPE&lt;/P&gt;&lt;P&gt;Resident TABLE_B;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Fields KEY_1,TYPE From TABLE_A;&lt;/P&gt;&lt;P&gt;DROP Fields KEY_1,TYPE From TABLE_B;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Join(TABLE_A)&lt;/P&gt;&lt;P&gt;LOAD * Resident TABLE_B;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table TABLE_B;&lt;/P&gt;&lt;P&gt;RENAME Table TABLE_A to TABLE_COMBINED;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS - not that i intended to answer myself, but it might help other peoples' time in answering the questions that needs real attention &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2015 15:35:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-model-with-combined-Key-issue/m-p/912634#M316700</guid>
      <dc:creator />
      <dc:date>2015-08-06T15:35:24Z</dc:date>
    </item>
  </channel>
</rss>

