<?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: How to avoid using Peek() and Order By in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642002#M235182</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table has 40 million rows and a total of 25 fields ( 5 GB on the qvd ), so yes, the amount of RAM needed is huge.&lt;/P&gt;&lt;P&gt;The table is calculated in the script after many transformations, so I can not do the ordering in the sql statment...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What about order the table on a LOAD and do the Peeks in a different load (with no ordering). Will that make any different?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 May 2014 14:04:31 GMT</pubDate>
    <dc:creator>luis_pimentel</dc:creator>
    <dc:date>2014-05-21T14:04:31Z</dc:date>
    <item>
      <title>How to avoid using Peek() and Order By</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642000#M235180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing a huge performance problem on a LOAD where I use the peek function many times, for different fields. &lt;STRONG&gt;This is a (very) simplified version&lt;/STRONG&gt; of my script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalTable:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp; MATXPeriod_KEY,&lt;/P&gt;&lt;P&gt;&amp;nbsp; If(IsNull([Total Stock]) AND previous(MATX_KEY) = MATX_KEY,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; peek([Inventory]),If(IsNull([Total Stock]),0,[Total Stock])) As [Inventory],&lt;/P&gt;&lt;P&gt;&amp;nbsp; If(IsNull([STPRS]) AND previous(MATX_KEY) = MATX_KEY,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; peek([Standard Price]),If(IsNull([STPRS]),0,[STPRS])) As [Standard Price]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resident SourceTable&lt;/P&gt;&lt;P&gt;Order by MATXPeriod_KEY;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SourceTable&lt;/EM&gt; has about 40 million rows, and the entire LOAD takes about 2 hours to finish. I am looking for a faster solution&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SourceTable &lt;/EM&gt;looks like&lt;EM&gt;:&lt;/EM&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="433"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" width="169"&gt;MATXPeriod_KEY&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="88"&gt;MATX_KEY&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="88"&gt;[Total Stock]&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="88"&gt;[STPRS]&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201101&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;50&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;12,34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201102&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;55&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201103&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;11,21&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201104&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201105&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;40&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;11,78&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201106&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;45&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201107&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;AA100|201108&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;AA100&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;90&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;BB200|201204&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;BB200&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;78,90&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;BB200|201205&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;BB200&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;77,67&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;BB200|201206&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;BB200&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;15&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;BB200|201207&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;BB200&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;78,34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;BB200|201208&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;BB200&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="border-top: none;"&gt;BB200|201209&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;BB200&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I basically need to "fill the blanks" with the first not-null previous value of each field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What about using a Intervalmatch? how could I implement it? This peek() function is very useful, but has a really bad performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already reviewed many of the post on this community regarding peek() function, but I did not find an alternative solution to avoid it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Luis.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 13:48:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642000#M235180</guid>
      <dc:creator>luis_pimentel</dc:creator>
      <dc:date>2014-05-21T13:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid using Peek() and Order By</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642001#M235181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is more likely that you reorder the table. You need to use a resident table for that. With 40 million rows that probably needs a lot of ram and cpu. If you get the data from an sql database you can try making that database do the ordering by adding the order by clause to the sql statement. If that's possible you won't need a resident table. Your load should be quicker then.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 13:56:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642001#M235181</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2014-05-21T13:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid using Peek() and Order By</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642002#M235182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table has 40 million rows and a total of 25 fields ( 5 GB on the qvd ), so yes, the amount of RAM needed is huge.&lt;/P&gt;&lt;P&gt;The table is calculated in the script after many transformations, so I can not do the ordering in the sql statment...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What about order the table on a LOAD and do the Peeks in a different load (with no ordering). Will that make any different?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 14:04:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642002#M235182</guid>
      <dc:creator>luis_pimentel</dc:creator>
      <dc:date>2014-05-21T14:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid using Peek() and Order By</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642003#M235183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe. That's something you can try out. But I don't expect it will help very much. &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If you now use resident tables a lot, perhaps you can store the intermediate result tables to qvd files. You then use the qvd as source instead of a resident table for the next transformation. But for an &lt;/SPAN&gt;&lt;EM style="font-size: 10pt; line-height: 1.5em;"&gt;order by&lt;/EM&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; you cannot avoid using a resident table.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 14:14:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-avoid-using-Peek-and-Order-By/m-p/642003#M235183</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2014-05-21T14:14:50Z</dc:date>
    </item>
  </channel>
</rss>

