<?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: join Intermatch 2 dates in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/join-Intermatch-2-dates/m-p/1759498#M719238</link>
    <description>&lt;P&gt;on high level, you need to relate the two tables row by row where the AccountKey are the same and the dates overlap.&amp;nbsp; to do this:&lt;BR /&gt;1. create a link table which is an outer join of the two tables on AccountKey; include keys for each table + the dates&lt;BR /&gt;2. then retain only the rows where the dates overlap&lt;BR /&gt;3. drop the AccountKey and the dates as you only need the keys to link back to the two tables.&lt;BR /&gt;&lt;BR /&gt;Obviously, AccountKey needs to have different names in the original tables.&amp;nbsp; &amp;nbsp;the relationship will look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_0-1604713312180.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/43752iE19C120A81E29792/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_0-1604713312180.png" alt="edwin_0-1604713312180.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the sample code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;table1: load %consentKey, %AccountKey, date(today()+offset1) as capDate, date(today()+offset2) as expDate inline [
%consentKey, %AccountKey,offset1, offset2
z0001, 1, -5, 5
z0002, 2, -2, 4
];

NoConcatenate table2: load %cycleKey, %AccountKey2, date(today()+offset1) as startDate, date(today()+offset2) as endDate inline [
%cycleKey, %AccountKey2, offset1, offset2
x0001, 1, -2, 3
x0002, 1, 6, 9
x0003, 2, -10, 1
x0004, 2, -10, -9
];

NoConcatenate
bridge1: load distinct %AccountKey, %consentKey, capDate as capDate2, expDate as expDate2 resident table1; 

inner join (bridge1)
load distinct %AccountKey2 as %AccountKey, %cycleKey, startDate as startDate2, endDate as endDate2 resident table2; 

NoConcatenate
bridge: load %consentKey, %cycleKey Resident bridge1
where capDate2&amp;gt;=startDate2 and expDate2 &amp;gt;=endDate2  and endDate2&amp;gt;=capDate2 or
capDate2&amp;lt;=startDate2 and expDate2 &amp;lt;=endDate2 and expDate2&amp;gt;=startDate2 or
capDate2 &amp;gt;=startDate2 and endDate2 &amp;gt;=expDate2 or
startDate2 &amp;gt;=capDate2 and expDate2&amp;gt;=endDate2;

drop table bridge1;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so only the ones that overlap will be associated:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_1-1604714677009.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/43753iC0794BA757DB713B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_1-1604714677009.png" alt="edwin_1-1604714677009.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;disclaimer: not sure if ive captured all the test cases for the overlapping dates - you need to add on to the where clause if there are other test cases.&lt;/P&gt;</description>
    <pubDate>Sat, 07 Nov 2020 02:05:44 GMT</pubDate>
    <dc:creator>edwin</dc:creator>
    <dc:date>2020-11-07T02:05:44Z</dc:date>
    <item>
      <title>join Intermatch 2 dates</title>
      <link>https://community.qlik.com/t5/QlikView/join-Intermatch-2-dates/m-p/1759450#M719237</link>
      <description>&lt;P&gt;Hi im having difficulty joining 2 tables based on start date and end date&lt;/P&gt;&lt;P&gt;i have 2 tables&amp;nbsp;&lt;/P&gt;&lt;P&gt;the &lt;STRONG&gt;Account Table&lt;/STRONG&gt; that has a unique &lt;STRONG&gt;consent ID&lt;/STRONG&gt; where the key is &lt;STRONG&gt;Account_Key&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;and the &lt;STRONG&gt;Cycle Table&lt;/STRONG&gt; where there is&amp;nbsp; also&lt;STRONG&gt;&amp;nbsp;Account_Key&lt;/STRONG&gt;&lt;BR /&gt;both tables have a &lt;STRONG&gt;start date &lt;/STRONG&gt;and &lt;STRONG&gt;end date. &lt;/STRONG&gt;or&lt;STRONG&gt; capture date&lt;/STRONG&gt; and&lt;STRONG&gt; expiration date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;i need to find out which &lt;STRONG&gt;Consent IDs&lt;/STRONG&gt;&amp;nbsp;from the&lt;STRONG&gt; Account Table ,&lt;/STRONG&gt; can be linked to which cycles&lt;/P&gt;&lt;P&gt;i can use a join Account -Account and then the&amp;nbsp;&lt;STRONG&gt;capture date &lt;/STRONG&gt;with intermatch to&amp;nbsp;&lt;STRONG&gt;start date &lt;/STRONG&gt;and &lt;STRONG&gt;end date.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;but i also want to include the records that fall&amp;nbsp; before the&amp;nbsp;&lt;STRONG&gt; expiration date, how can i achieve this&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="anwarbham_0-1604698788385.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/43746iC6C73BADA621B8B4/image-size/large?v=v2&amp;amp;px=999" role="button" title="anwarbham_0-1604698788385.png" alt="anwarbham_0-1604698788385.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:40:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/join-Intermatch-2-dates/m-p/1759450#M719237</guid>
      <dc:creator>anwarbham</dc:creator>
      <dc:date>2024-11-15T23:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: join Intermatch 2 dates</title>
      <link>https://community.qlik.com/t5/QlikView/join-Intermatch-2-dates/m-p/1759498#M719238</link>
      <description>&lt;P&gt;on high level, you need to relate the two tables row by row where the AccountKey are the same and the dates overlap.&amp;nbsp; to do this:&lt;BR /&gt;1. create a link table which is an outer join of the two tables on AccountKey; include keys for each table + the dates&lt;BR /&gt;2. then retain only the rows where the dates overlap&lt;BR /&gt;3. drop the AccountKey and the dates as you only need the keys to link back to the two tables.&lt;BR /&gt;&lt;BR /&gt;Obviously, AccountKey needs to have different names in the original tables.&amp;nbsp; &amp;nbsp;the relationship will look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_0-1604713312180.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/43752iE19C120A81E29792/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_0-1604713312180.png" alt="edwin_0-1604713312180.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the sample code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;table1: load %consentKey, %AccountKey, date(today()+offset1) as capDate, date(today()+offset2) as expDate inline [
%consentKey, %AccountKey,offset1, offset2
z0001, 1, -5, 5
z0002, 2, -2, 4
];

NoConcatenate table2: load %cycleKey, %AccountKey2, date(today()+offset1) as startDate, date(today()+offset2) as endDate inline [
%cycleKey, %AccountKey2, offset1, offset2
x0001, 1, -2, 3
x0002, 1, 6, 9
x0003, 2, -10, 1
x0004, 2, -10, -9
];

NoConcatenate
bridge1: load distinct %AccountKey, %consentKey, capDate as capDate2, expDate as expDate2 resident table1; 

inner join (bridge1)
load distinct %AccountKey2 as %AccountKey, %cycleKey, startDate as startDate2, endDate as endDate2 resident table2; 

NoConcatenate
bridge: load %consentKey, %cycleKey Resident bridge1
where capDate2&amp;gt;=startDate2 and expDate2 &amp;gt;=endDate2  and endDate2&amp;gt;=capDate2 or
capDate2&amp;lt;=startDate2 and expDate2 &amp;lt;=endDate2 and expDate2&amp;gt;=startDate2 or
capDate2 &amp;gt;=startDate2 and endDate2 &amp;gt;=expDate2 or
startDate2 &amp;gt;=capDate2 and expDate2&amp;gt;=endDate2;

drop table bridge1;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so only the ones that overlap will be associated:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_1-1604714677009.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/43753iC0794BA757DB713B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_1-1604714677009.png" alt="edwin_1-1604714677009.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;disclaimer: not sure if ive captured all the test cases for the overlapping dates - you need to add on to the where clause if there are other test cases.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 02:05:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/join-Intermatch-2-dates/m-p/1759498#M719238</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2020-11-07T02:05:44Z</dc:date>
    </item>
  </channel>
</rss>

