<?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: Complex Join in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238863#M24522</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ended up using Interval Match to solve this issue.&amp;nbsp; That allowed me to select the appropriate based on the date of the record and the date range attached to the override.&amp;nbsp; If anyone needs help applying this to their model, let me know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Apr 2017 22:47:02 GMT</pubDate>
    <dc:creator>flottmen</dc:creator>
    <dc:date>2017-04-18T22:47:02Z</dc:date>
    <item>
      <title>Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238856#M24515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table that is full of transactions.&amp;nbsp; These transactions have a date entered, a campaign id and an affiliate id (among other things).&amp;nbsp; I need to join this transaction table to a table of overrides.&amp;nbsp; These overrides join on a combination of campaign id and affiliate id (easy so far).&amp;nbsp; However, multiple overrides can be created over time.&amp;nbsp; For this join, I need to join only the most recent override that was added prior to the transaction being created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my script so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN ([table])&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp; AffiliateId,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CampaignId,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstSortedValue(override_value, -Override_DateEffective) AS Override_Value&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;RESIDENT [override_table]&lt;/P&gt;&lt;P&gt;WHERE Override_DateEffective &amp;lt; Transaction_DateEntered&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems to me that the Where clause should only allow the join to accept overrides that existed prior to the transaction.&amp;nbsp; Then the FirstSortedValue function selects the most recent of these values (the one I want).&amp;nbsp; However, the Transaction_DateEntered is not visible to query.&amp;nbsp; Can I use a PEEK?&amp;nbsp; If so, how do I determine the row number for that function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Mar 2017 23:05:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238856#M24515</guid>
      <dc:creator>flottmen</dc:creator>
      <dc:date>2017-03-06T23:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238857#M24516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe you couldn't do it with a single join-statement else you would need further steps to limit this override-load or to filter unwanted records after the join. Therefore I think a mapping approach with a composite key of campaign id + affiliate id and your override value will be more suitable. An applymap() will catch the value from the first matching like a lookup in excel and if your mapping-table is properly ordered to the most recent transaction date it should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Mar 2017 08:53:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238857#M24516</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2017-03-07T08:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238858#M24517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you need to load all the overrides? It sounds to me like you should load only the most recent overrides, in which case the join is a simpler (and quicker).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Mar 2017 09:46:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238858#M24517</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2017-03-07T09:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238859#M24518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I simplified the example I gave.&amp;nbsp; I actually need to join an entire row (four columns) of data from the override table.&amp;nbsp; The Apply Map logic seems to restrict my map to one field only.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Mar 2017 17:36:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238859#M24518</guid>
      <dc:creator>flottmen</dc:creator>
      <dc:date>2017-03-07T17:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238860#M24519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's not a problem because you could concat your fields like: F1 &amp;amp; '|' &amp;amp; F2 &amp;amp; '|' &amp;amp; F3 &amp;amp; '|' &amp;amp; F4 and then you could use subfield(applymap('MapName', YourKey, '#NV'), '|', 1) as F1 to get your values splitted again. That's not uncommon and also quite fast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Mar 2017 18:06:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238860#M24519</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2017-03-07T18:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238861#M24520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a simplified example that highlights my problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Overrides]:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp; Id, Date, Amount&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, '1-1-16', 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 2-1-16', 18&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Transactions]:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp; Id, Date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, '1-3-16',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, '1-5-16',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, '1-30-16',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, '2-2-16',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, '2-20-16'&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Map_Overrides]:&lt;/P&gt;&lt;P&gt;MAPPING LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; Id, Amount&lt;/P&gt;&lt;P&gt;RESIDENT [Overrides];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Transaction_Override]:&lt;/P&gt;&lt;P&gt;LOAD Id,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Date(Date#(Date, 'MM-DD-YY'), 'MM/DD/YYYY') AS Date,&lt;/P&gt;&lt;P&gt;&amp;nbsp; ApplyMap('Map_Overrides', Id) AS Override&lt;/P&gt;&lt;P&gt;RESIDENT [Transactions];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;DROP TABLE [Transactions];&lt;/P&gt;&lt;P&gt;DROP TABLE [Overrides];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even using Mapping all of the transactions are getting the $20 override.&amp;nbsp; I need the two transactions in February to map to the $18 override that was made effective on 2-1-16.&amp;nbsp; What logic can I add to this to make it work?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Mar 2017 22:30:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238861#M24520</guid>
      <dc:creator>flottmen</dc:creator>
      <dc:date>2017-03-07T22:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238862#M24521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is no sorting within your mapping-load - add just the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Map_Overrides]:&lt;/P&gt;&lt;P&gt;MAPPING LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; Id, Amount&lt;/P&gt;&lt;P&gt;RESIDENT [Overrides]&lt;STRONG&gt; order by Date desc&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2017 08:03:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238862#M24521</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2017-03-08T08:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Join</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238863#M24522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ended up using Interval Match to solve this issue.&amp;nbsp; That allowed me to select the appropriate based on the date of the record and the date range attached to the override.&amp;nbsp; If anyone needs help applying this to their model, let me know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Apr 2017 22:47:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join/m-p/1238863#M24522</guid>
      <dc:creator>flottmen</dc:creator>
      <dc:date>2017-04-18T22:47:02Z</dc:date>
    </item>
  </channel>
</rss>

