<?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 Create a table from date ranges. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570333#M683444</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a set of data (32m records) that has a start and end years each record. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this for any type of calculation is very slow and very complicated. We need to know if a particular record feels in a particular year. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this, we are trying to build a table that has a row that contain the key fields and a year. That year would be all the years between start and end. so if a particular records goes from 2003 to 2012, we will have a table that has&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="144" style="border: 1px solid rgb(0, 0, 0); width: 114px; height: 102px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Key&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;key&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;key&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;key&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We alredy try two ways to do this, and all of them works. But they take more than 6 hours to run (a lot more).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One of them goes all the table all the time adding one year at a time for each key. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the other has all the diference between start and end, builds a table that has all the years, and then concatenate it to the original table. This works better than the other one, but takes around a minute for each start-end row (and they are about 3500 in a select disticnt)...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So any one has a better idea on how to build this table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Feb 2014 16:52:56 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-02-11T16:52:56Z</dc:date>
    <item>
      <title>Create a table from date ranges.</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570333#M683444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a set of data (32m records) that has a start and end years each record. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this for any type of calculation is very slow and very complicated. We need to know if a particular record feels in a particular year. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this, we are trying to build a table that has a row that contain the key fields and a year. That year would be all the years between start and end. so if a particular records goes from 2003 to 2012, we will have a table that has&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="144" style="border: 1px solid rgb(0, 0, 0); width: 114px; height: 102px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Key&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;key&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;key&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;key&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We alredy try two ways to do this, and all of them works. But they take more than 6 hours to run (a lot more).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One of them goes all the table all the time adding one year at a time for each key. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the other has all the diference between start and end, builds a table that has all the years, and then concatenate it to the original table. This works better than the other one, but takes around a minute for each start-end row (and they are about 3500 in a select disticnt)...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So any one has a better idea on how to build this table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2014 16:52:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570333#M683444</guid>
      <dc:creator />
      <dc:date>2014-02-11T16:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table from date ranges.</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570334#M683445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Typically it's done with something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD Key, StartYear + iterno() -1 as Year&lt;/P&gt;&lt;P&gt;FROM MyTableWith32MRecords.qvd (qvd)&lt;/P&gt;&lt;P&gt;while StartYear + iterno() -1 &amp;lt;= EndYear;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2014 17:34:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570334#M683445</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2014-02-11T17:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table from date ranges.</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570335#M683446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Id doesn't seems so heavy, I just tried with this script (only 4M, not 32) and it only took me 90 seconds, including rows generation and qvd store, the log is attached&lt;/P&gt;&lt;P&gt;or I didn't understand?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;directory;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Characters:&lt;/P&gt;&lt;P&gt;Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASCII:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;if(RecNo()&amp;gt;=65 and RecNo()&amp;lt;=90,RecNo()-64) as Num,&lt;/P&gt;&lt;P&gt;Chr(RecNo()) as AsciiAlpha,&lt;/P&gt;&lt;P&gt;RecNo() as AsciiNum&lt;/P&gt;&lt;P&gt;autogenerate 255&lt;/P&gt;&lt;P&gt;Where (RecNo()&amp;gt;=32 and RecNo()&amp;lt;=126) or RecNo()&amp;gt;=160 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;autonumber(TransID &amp;amp; TransLineID) as Id,&lt;/P&gt;&lt;P&gt;year(floor(today() + rand()*1000)) as YearFrom,&lt;/P&gt;&lt;P&gt;year(floor(today() + 1000 + rand()*4000)) as YearTo,&lt;/P&gt;&lt;P&gt;TransLineID,&lt;/P&gt;&lt;P&gt;TransID,&lt;/P&gt;&lt;P&gt;mod(TransID,26)+1 as Num,&lt;/P&gt;&lt;P&gt;Pick(Ceil(6*Rand1),'a','b','c','d','e','f') as Dim2,&lt;/P&gt;&lt;P&gt;Round(1000*Rand()*Rand()*Rand1) as Expression1&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Rand() as Rand1,&lt;/P&gt;&lt;P&gt;IterNo() as TransLineID,&lt;/P&gt;&lt;P&gt;RecNo() as TransID&lt;/P&gt;&lt;P&gt;Autogenerate 2000000&lt;/P&gt;&lt;P&gt;While Rand()&amp;lt;=0.5 or IterNo()=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STORE Table into Table.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;YearTable:&lt;/P&gt;&lt;P&gt;NoConcatenate load&lt;/P&gt;&lt;P&gt;Id,&lt;/P&gt;&lt;P&gt;YearFrom + IterNo() -1 as Year&lt;/P&gt;&lt;P&gt;From Table.qvd (qvd)&lt;/P&gt;&lt;P&gt;While IterNo()-1 + YearFrom &amp;lt;= YearTo;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Characters &amp;lt;&amp;lt; AUTOGENERATE(26) 26 lines fetched&lt;/P&gt;&lt;P&gt;ASCII &amp;lt;&amp;lt; AUTOGENERATE(255) 191 lines fetched&lt;/P&gt;&lt;P&gt;Table &amp;lt;&amp;lt; AUTOGENERATE(2000000) 4.003.506 lines fetched&lt;/P&gt;&lt;P&gt;YearTable &amp;lt;&amp;lt; Table 31.376.589 lines fetched&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2014 18:08:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570335#M683446</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-02-11T18:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table from date ranges.</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570336#M683447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My tries were heavy. Gysbert Idea is running and looks a lot faster than mine...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2014 18:13:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-table-from-date-ranges/m-p/570336#M683447</guid>
      <dc:creator />
      <dc:date>2014-02-11T18:13:25Z</dc:date>
    </item>
  </channel>
</rss>

