<?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: Create a new table based on date comparison in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042996#M935531</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to extent your costprice-table to an additional column "ValidTo" which you could get from the previous record in an appropriate sorted resident-load per &lt;A href="https://community.qlik.com/docs/DOC-9314"&gt;Peek() or Previous() ?&lt;/A&gt;. And then you could use &lt;A href="https://community.qlik.com/qlik-blogpost/3037"&gt;IntervalMatch&lt;/A&gt; to match these dates to your sales-table.&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, 17 Feb 2016 09:23:51 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2016-02-17T09:23:51Z</dc:date>
    <item>
      <title>Create a new table based on date comparison</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042995#M935530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;got two tables,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sales:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screenshot3.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/114791_Screenshot3.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;CostPrice:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screenshot4.PNG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/114792_Screenshot4.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;The CostPricePrSoldVolume for an Item is Valid until an newer date (ValidFrom) for that Item occurs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Need to find the valid CostPricePrSoldVolume for each Item at the Sales.Date, by comparing ValidFrom and Sales.Date, and multiply &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;CostPricePrSoldVolume&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; with SalesVolume.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Want to create a new table in script, which should look like this:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screenshot5.PNG" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/114793_Screenshot5.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt; Item 4 should not appear in the result, because it is not sold.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2016 10:51:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042995#M935530</guid>
      <dc:creator />
      <dc:date>2016-02-16T10:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new table based on date comparison</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042996#M935531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to extent your costprice-table to an additional column "ValidTo" which you could get from the previous record in an appropriate sorted resident-load per &lt;A href="https://community.qlik.com/docs/DOC-9314"&gt;Peek() or Previous() ?&lt;/A&gt;. And then you could use &lt;A href="https://community.qlik.com/qlik-blogpost/3037"&gt;IntervalMatch&lt;/A&gt; to match these dates to your sales-table.&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, 17 Feb 2016 09:23:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042996#M935531</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2016-02-17T09:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new table based on date comparison</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042997#M935532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Set DateFormat='DD.MM.YYYY';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sales:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD Item,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; SalesVolume,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Date(Day) as Date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;INLINE [&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Item, SalesVolume, Day&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 5, 04.01.2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 4, 11.01.2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 7, 01.02.2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2, 5, 04.01.2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 4, 10.01.2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 5, 16.01.2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CostPrice:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD Item,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Date(ValidFrom) as ValidFrom,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; CostPricePrSoldVolume&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;INLINE [&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Item, ValidFrom, CostPricePrSoldVolume&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 01.01.2016, 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 01.02.2016, "1,5"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 01.01.2016, 4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 15.02.2016, 5&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4, 01.01.2016, 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FinalCostPrice:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD *,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Date(If(Peek('Item') = Item, Peek('ValidFrom') - 1, Today())) as ValidUntil&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident CostPrice&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Order By Item, ValidFrom desc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table CostPrice;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Left Join (Sales)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IntervalMatch (Date, Item)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD ValidFrom,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; ValidUntil,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Item&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident FinalCostPrice;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Left Join (Sales)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD *&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident FinalCostPrice;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table FinalCostPrice;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FinalTable:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD *,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; SalesVolume * CostPricePrSoldVolume as CostPriceTotal&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Sales;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table Sales;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/114929_Capture.PNG" style="height: auto;" /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 09:54:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042997#M935532</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-02-17T09:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new table based on date comparison</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042998#M935533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, thx!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Feb 2016 10:08:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-new-table-based-on-date-comparison/m-p/1042998#M935533</guid>
      <dc:creator />
      <dc:date>2016-02-17T10:08:11Z</dc:date>
    </item>
  </channel>
</rss>

