<?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: Sorting table in script ? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013750#M644274</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;Delta:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD id, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; site, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; partionkey, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; modifieddate as modifieddatetemp, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sale&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[Modi Test.txt]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; YEAR_MONTH_CALENDAR:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; LOAD Distinct&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; timestamp(Monthstart(partionkey)) as MonthStart,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; timestamp(MonthEnd(partionkey)) as MonthEnd,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Year(floor(partionkey))&amp;amp;NUM(Month(floor(partionkey)),'00') AS MonthName,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; modifieddatetemp as modifieddate&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Resident Delta&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Order by modifieddatetemp desc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FinalDelta:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD id,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; site,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; partionkey,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; modifieddatetemp as modifieddate,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; sale&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Delta;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table Delta;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataViewer is still incorrect sorting, but when you sort the data by load order in table box it shows the right sorting which means that the data is being correctly sorted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/111814_Capture.PNG" style="height: 406px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 17 Jan 2016 20:32:06 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2016-01-17T20:32:06Z</dc:date>
    <item>
      <title>Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013749#M644273</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 have a senario where the temporary calender needs to be sorted in desending order of modified date, but i am unable to sort that table in script. Please find attached files.&lt;/P&gt;&lt;P&gt;Note: As i got huge number of records i need to use distinct in that table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="tab.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/111802_tab.PNG" style="height: 221px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Ganesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jan 2016 20:21:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013749#M644273</guid>
      <dc:creator>ganeshreddy</dc:creator>
      <dc:date>2016-01-17T20:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013750#M644274</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;Delta:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD id, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; site, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; partionkey, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; modifieddate as modifieddatetemp, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sale&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[Modi Test.txt]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; YEAR_MONTH_CALENDAR:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; LOAD Distinct&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; timestamp(Monthstart(partionkey)) as MonthStart,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; timestamp(MonthEnd(partionkey)) as MonthEnd,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Year(floor(partionkey))&amp;amp;NUM(Month(floor(partionkey)),'00') AS MonthName,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; modifieddatetemp as modifieddate&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Resident Delta&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Order by modifieddatetemp desc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FinalDelta:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD id,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; site,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; partionkey,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; modifieddatetemp as modifieddate,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; sale&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Delta;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table Delta;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataViewer is still incorrect sorting, but when you sort the data by load order in table box it shows the right sorting which means that the data is being correctly sorted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/111814_Capture.PNG" style="height: 406px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jan 2016 20:32:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013750#M644274</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-01-17T20:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013751#M644275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ganesh,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;There are very few cases where sorting in the load script is necessary.&amp;nbsp; Using PEEK or doing an incremental load are the only cases I can think of.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;In the main sorting in the front end makes much more sense.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why do you think that sorting in the script is required?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are some cases where the ORDER BY statement can not be used, loading from QVD for instance.&amp;nbsp; In these cases you can load to a temporary table and sort on the load from RESIDENT, as &lt;A href="https://community.qlik.com/qlik-users/171708"&gt;sunindia&lt;/A&gt;‌ suggests.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The downside of this is it can make your load script take twice the time to execute.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This DISTINCT predicate can put put in to any type of load, and will remove all duplicate rows - use with caution though as it can cause duplicate values to go missing - giving incorrect totals.&amp;nbsp; A GROUP BY with SUM statements is usually preferable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jan 2016 20:42:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013751#M644275</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2016-01-17T20:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013752#M644276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply sunny,&lt;/P&gt;&lt;P&gt;I need to use this calender table further in script not in UI. Here we are getting &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;DataViewer&lt;/SPAN&gt; results only, because if i use peek function as mentioned below it is fetching the wrong record .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; peek('&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;modifieddate&lt;/STRONG&gt;',-1,'&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;YEAR_MONTH_CALENDAR&lt;/STRONG&gt;');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My actual requirement is to sort months in desending order of modified date. Could you please help me out here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ganesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jan 2016 20:48:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013752#M644276</guid>
      <dc:creator>ganeshreddy</dc:creator>
      <dc:date>2016-01-17T20:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013753#M644277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ganesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I notice you have a semi colon on the end of that statement, is this statement run on it's own after the load.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do the sorted resident load, as recommended then this will give you the last modified date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More efficient would be to load the table in any order then do a resident LOAD with a GROUP BY and a MAX or a MIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You only need to sort for a peek if you are referring back to the previous row in a load for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ModifiedDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ModifiedDate - Peek('ModifiedDate', -1) as DaysSincePriorChange,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jan 2016 20:58:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013753#M644277</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2016-01-17T20:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013754#M644278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes your assumption is correct, i am doing incrimental load with that calender table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Here &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;sorting in the script is required , because it is a monthly QVD updation is there futher in script. Please find&amp;nbsp; metioned pseudo code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Delta:&lt;/P&gt;&lt;P&gt;LOAD id, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; site, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partionkey, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modifieddate, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sale&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[Modi Test.txt]&lt;/P&gt;&lt;P&gt;(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; YEAR_MONTH_CALENDAR:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp; distinct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp(Monthstart(partionkey)) as MonthStart,&lt;/P&gt;&lt;P&gt;&amp;nbsp; timestamp(MonthEnd(partionkey)) as MonthEnd,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year(floor(partionkey))&amp;amp;NUM(Month(floor(partionkey)),'00') AS MonthName,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modifieddate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Resident Delta Order by modifieddate desc;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Let vCount=NoOfRows('YEAR_MONTH_CALENDAR');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/********************* Loop through each month generated in 'YEAR_MONTH_CALENDAR' table ***************************/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; FOR i=1 to $(vCount)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vMonth = Peek('MonthName',-$(i),'YEAR_MONTH_CALENDAR');&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vMonthStart = Peek('MonthStart',-$(i),'YEAR_MONTH_CALENDAR');&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vMonthEnd = Peek('MonthEnd',-$(i),'YEAR_MONTH_CALENDAR');&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vTableName =&amp;nbsp; 'Result' &amp;amp; '$(vMonth)' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LET vReloadTimeIn = Now();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /********** If QVD for YearMonth already exists Insert/Update to the existing QVD based on primary key, or else move to ELSE part to create new QVD for that month*******/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(not IsNull(FileTime('$(vQVDDataDir)\$(vTableName).qvd'))) then&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; [$(vTableName)]:&lt;/P&gt;&lt;P&gt;&amp;nbsp; NoConcatenate&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Resident Delta&lt;/P&gt;&lt;P&gt;&amp;nbsp; Where Year(floor(PartitionKey))&amp;amp;NUM(Month(floor(PartitionKey)),'00')='$(vMonth)';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; CONCATENATE&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp; * &lt;/P&gt;&lt;P&gt;&amp;nbsp; FROM [$(vQVDDataDir)\$(vTableName).qvd] (qvd)&lt;/P&gt;&lt;P&gt;&amp;nbsp; WHERE NOT EXISTS (ID);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [$(vTableName)]:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NoConcatenate&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Resident Delta&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where Year(floor(PartitionKey))&amp;amp;NUM(Month(floor(PartitionKey)),'00')='$(vMonth)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Drop table Delta;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above script i need to create a calender table with &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;desending order of modified date which i am unable to do so far. Is there any other whay out to sort that table? Could you please help me out here.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ganesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jan 2016 21:14:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013754#M644278</guid>
      <dc:creator>ganeshreddy</dc:creator>
      <dc:date>2016-01-17T21:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013755#M644279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here the reason for soring with modified date is. Some times data base is updating any of previous months records only. It is a rare case as incrimental load with montly QVDs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ganesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jan 2016 21:22:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013755#M644279</guid>
      <dc:creator>ganeshreddy</dc:creator>
      <dc:date>2016-01-17T21:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013756#M644280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ganesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get the importance of the sorting now, the WHERE EXISTS wanting to see new records first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem you have is that the date is loading from the TXT file, so is inherently not a date, but is a text string.&amp;nbsp; When you sort (and the syntax for ORDER BY is correct in the script above) it is sorting as a string, not as a date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To solve this you will need to convert the date on load, like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Delta:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LOAD id,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; site,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; partionkey,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; Date#(modifieddate, 'YYYY-MM-DD hh:mm:ss') as modifieddate,&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sale&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;[Modi Test.txt]&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Here it is critical that the date format string matches the format of the dates in the text file.&amp;nbsp; You can add a &lt;STRONG&gt;Date&lt;/STRONG&gt; function around that code ( &lt;STRONG&gt;Date(Date#(&lt;/STRONG&gt; ) to format the output - but if it is just used for sorting this is not important.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I suspect that you also want to do similar to partionkey, if that is also a date.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;The easy way to test if that bit of code is working is to load the data from the text file in isolation and do a list box on modifieddate.&amp;nbsp; If it sorts right in a a ListBox then it will sort fine with an ORDER BY from a RESIDENT load.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Hope that helps,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 07:55:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013756#M644280</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2016-01-18T07:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013757#M644282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot, i worked with your suggestions. My requirement is fulfilled now. Final work file and data file are attached to this post. PFA&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Desired Order.PNG" class="jive-image image-1" src="/legacyfs/online/112069_Desired Order.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Ganesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 07:26:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013757#M644282</guid>
      <dc:creator>ganeshreddy</dc:creator>
      <dc:date>2016-01-20T07:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting table in script ?</title>
      <link>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013758#M644284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it's now working.&amp;nbsp; Thanks for sharing the solution.&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 08:07:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sorting-table-in-script/m-p/1013758#M644284</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2016-01-20T08:07:02Z</dc:date>
    </item>
  </channel>
</rss>

