<?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 Problem in order by while loading in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294790#M706191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, this could be a solution, but it will result in a slower loading, so I am still trying to solve this working on the initialization:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LET varMinDate = Num(Peek('DATEMOV', 0, 'Sales'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LET varMaxDate = Num(Peek('DATEMOV', -1, 'Sales'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;trying to find some other function to reach the same result&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Jan 2012 16:45:49 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-01-24T16:45:49Z</dc:date>
    <item>
      <title>Problem in order by while loading</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294788#M706189</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;I have a little problem in my loading script, here's the code that don't work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;Sales:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;&amp;nbsp;&amp;nbsp; [...fields, including the date DATAMOV...]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;SQL SELECT *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;FROM QLIK.SALES&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;ORDER BY DATEMOV ASC;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LET varMinDate = Num(Peek('DATEMOV', 0, 'Sales'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LET varMaxDate = Num(Peek('DATEMOV', -1, 'Sales'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LET varToday = num(today());&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;// Temporary calendar //&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;DateField:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(varMinDate) + RowNo() - 1 as Num,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date($(varMinDate) + RowNo() - 1) as TempDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;AutoGenerate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(varMaxDate) - $(varMinDate) + 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code will create the temporary table DateField that I use to build a calendar.&lt;/P&gt;&lt;P&gt;The problem is that varMinDate and varMaxDate are both &amp;lt;NULL&amp;gt; and the execution throws an exception, but if I remove the line "ORDER BY DATEMOV ASC", it will work fine.&lt;/P&gt;&lt;P&gt;Unfortunately I cannot assume that the rows in the table "Sales" are ordered per DATEMOV in the source database.&lt;/P&gt;&lt;P&gt;The table Sales could have up to 3.000.000 rows, but I think this is not the problem.&lt;/P&gt;&lt;P&gt;So anyone knows a method to correctly initialize varMinDate and varMaxDate, or a possible explanation of why I get this error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Carlo A.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2012 16:05:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294788#M706189</guid>
      <dc:creator />
      <dc:date>2012-01-20T16:05:48Z</dc:date>
    </item>
    <item>
      <title>Problem in order by while loading</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294789#M706190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Carlo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you might face is that the "order by" clause doesn't work when loading data from a qvd file.&lt;/P&gt;&lt;P&gt;But here your data is loaded directly from database and I'm not sure if it's the same case (will have to try it tomorrow at work).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a solution, you can load your data first into a temp table without the "order by" clause, then do a resident load where you can order. It would go like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tempSales:&lt;/P&gt;&lt;P&gt;LOAD ...&lt;/P&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;FROM QLIK.SALES;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sales:&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;LOAD *&lt;/P&gt;&lt;P&gt;Resident tempSales&lt;/P&gt;&lt;P&gt;Order By DATEMOV;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table tempSales;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET varMinDate = ... //continue with your actual script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jan 2012 03:31:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294789#M706190</guid>
      <dc:creator />
      <dc:date>2012-01-22T03:31:56Z</dc:date>
    </item>
    <item>
      <title>Problem in order by while loading</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294790#M706191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, this could be a solution, but it will result in a slower loading, so I am still trying to solve this working on the initialization:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LET varMinDate = Num(Peek('DATEMOV', 0, 'Sales'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;LET varMaxDate = Num(Peek('DATEMOV', -1, 'Sales'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: trebuchet ms,geneva;"&gt;trying to find some other function to reach the same result&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jan 2012 16:45:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294790#M706191</guid>
      <dc:creator />
      <dc:date>2012-01-24T16:45:49Z</dc:date>
    </item>
    <item>
      <title>Problem in order by while loading</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294791#M706192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Carlo,&lt;/P&gt;&lt;P&gt;You can load temp table containing only max date and min date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Max(Date) as Maxdate,&lt;/P&gt;&lt;P&gt;Min(Date) as MinDate&lt;/P&gt;&lt;P&gt;resident tempsales;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let varMinDate=Fieldvalue(MaXDate,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let varMinDate=Fieldvalue(MinDate,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jan 2012 05:26:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294791#M706192</guid>
      <dc:creator>vijay_iitkgp</dc:creator>
      <dc:date>2012-01-25T05:26:28Z</dc:date>
    </item>
    <item>
      <title>Problem in order by while loading</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294792#M706193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay, I tried to use your solution and it works! thank you so much&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2012 09:57:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-in-order-by-while-loading/m-p/294792#M706193</guid>
      <dc:creator />
      <dc:date>2012-02-10T09:57:49Z</dc:date>
    </item>
  </channel>
</rss>

