<?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: Left Join and Max Date in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Left-Join-and-Max-Date/m-p/1958650#M79024</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/190531"&gt;@LS67&lt;/a&gt;&amp;nbsp; Sorry I am not able to completely understand your requirement. Could you please elaborate and also provide some sample data for us to look into it?&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jul 2022 06:38:32 GMT</pubDate>
    <dc:creator>sidhiq91</dc:creator>
    <dc:date>2022-07-21T06:38:32Z</dc:date>
    <item>
      <title>Left Join and Max Date</title>
      <link>https://community.qlik.com/t5/App-Development/Left-Join-and-Max-Date/m-p/1958487#M79015</link>
      <description>&lt;P&gt;Hi everybody,&lt;BR /&gt;I have a table looking like this (Ref% is referreing to a Key number):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LS67_0-1658332318631.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/84686i45D0C4C9C01C812D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LS67_0-1658332318631.png" alt="LS67_0-1658332318631.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I would like to create a new field "Good_Ref" based on the value of "Ref_Ava" (in the script, you will see the field "OrderNumber" i/o "Ref_Ava") for each set of data based on "MasterKey" and considering the following conditions :&lt;/P&gt;
&lt;P&gt;- If multiple trade dates : Good_Ref = Ref_Ava where Role = Market or Client AND Trade Date = Max Date for each set of data with the same “MasterKey”&lt;/P&gt;
&lt;P&gt;- Else : Good_Ref = Ref_Ava where Role = Market or Client. If 2 references have a Role = Market or Client but two different ISIN for a same MasterKey, than I want to keep both lines and references.&lt;BR /&gt;To illustrate, I wish to have in result this table :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LS67_1-1658332331719.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/84687i943F87DDEF736491/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LS67_1-1658332331719.png" alt="LS67_1-1658332331719.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, for now, I have the wrong reference when trade dates are different :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LS67_2-1658332342181.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/84688iAE0B684F7458FCE8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LS67_2-1658332342181.png" alt="LS67_2-1658332342181.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here after you can see the script I wrote in the Data Load Editor :&lt;BR /&gt;[Data]:&lt;BR /&gt;LOAD&lt;BR /&gt;* &lt;BR /&gt;FROM TABLE (qvd);&lt;/P&gt;
&lt;P&gt;[TABLE_REF]:&lt;BR /&gt;LOAD&lt;BR /&gt;[MasterKey],&lt;BR /&gt;[OrderNumber] AS [Good_Ref],&lt;BR /&gt;[ISIN],&lt;BR /&gt;[TradeDate],&lt;BR /&gt;Resident [Data]&lt;BR /&gt;where ([OrderRole]='Market’ or ([OrderRole]='Client’));&lt;/P&gt;
&lt;P&gt;Inner Join ([TABLE_REF])&lt;BR /&gt;LOAD&lt;BR /&gt;date(Max([TradeDate]),'YYYY-MM-DD') as [TradeDate2],&lt;BR /&gt;[MasterKey],&lt;BR /&gt;[ISIN]&lt;BR /&gt;Resident [Data]&lt;BR /&gt;Group by [MasterKey], [ISIN];&lt;/P&gt;
&lt;P&gt;[TABLE_REF2]:&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Load&lt;BR /&gt;[MasterKey],&lt;BR /&gt;[ISIN],&lt;BR /&gt;[TradeDate2],&lt;BR /&gt;[Good_Ref],&lt;BR /&gt;Resident [TABLE_REF];&lt;/P&gt;
&lt;P&gt;Left Join [Data]:&lt;BR /&gt;Load&lt;BR /&gt;[MasterKey],&lt;BR /&gt;[ISIN],&lt;BR /&gt;[TradeDate2],&lt;BR /&gt;[Good_Ref],&lt;BR /&gt;Resident [TABLE_REF2];&lt;/P&gt;
&lt;P&gt;Drop Table [TABLE_REF];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be happy if someone can help on this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Laetitia&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 16:14:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Left-Join-and-Max-Date/m-p/1958487#M79015</guid>
      <dc:creator>LS67</dc:creator>
      <dc:date>2022-07-20T16:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join and Max Date</title>
      <link>https://community.qlik.com/t5/App-Development/Left-Join-and-Max-Date/m-p/1958650#M79024</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/190531"&gt;@LS67&lt;/a&gt;&amp;nbsp; Sorry I am not able to completely understand your requirement. Could you please elaborate and also provide some sample data for us to look into it?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 06:38:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Left-Join-and-Max-Date/m-p/1958650#M79024</guid>
      <dc:creator>sidhiq91</dc:creator>
      <dc:date>2022-07-21T06:38:32Z</dc:date>
    </item>
  </channel>
</rss>

