<?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: Autogenerate dates for each table row in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018506#M344877</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand that one correctly at first glance then it is about generating those dates once globally. I need to do this per table row which doesn't work out for me using a cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Mar 2016 12:33:35 GMT</pubDate>
    <dc:creator>benjamins</dc:creator>
    <dc:date>2016-03-07T12:33:35Z</dc:date>
    <item>
      <title>Autogenerate dates for each table row</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018503#M344874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table A with an Id and two date columns which describe each element's availabililty (begin and end):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Id&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Begin&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;End&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;2016-01-01&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;2016-01-09&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;2016-01-01&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;2016-01-15&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;2016-01-11&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; 2016-01-17&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the first element would be available from 1st of January to 9th of January and so on.&lt;/P&gt;&lt;P&gt;I'd like to create a table B from this information which contains all dates on which each element would be available.&lt;/P&gt;&lt;P&gt;So this table should have two columns "Id" and "ElementDateId" and contain 31 records total (9 for element 1, 15 for 2 and 7 for 3).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd have suspected something like the following (please also see the attached sample), however this doesn't seem to work out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;QV_A:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;, date(Begin) as BeginDate&lt;/P&gt;&lt;P&gt;, date(End) as EndDate&lt;/P&gt;&lt;P&gt;Resident QV_TEMP_A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Drop Table QV_TEMP_A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;QV_GENERATE_A:&lt;/P&gt;&lt;P&gt;LOAD ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; floor(EndDate) - floor(BeginDate) + 1 as num_days,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; floor(BeginDate) as floor_begin&lt;/P&gt;&lt;P&gt;Resident QV_A;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For vValueNo = 1 to num_days&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; floor_begin + $(vValueNo) -1 as ElementDateId&lt;/P&gt;&lt;P&gt;AUTOGENERATE num_days;&lt;/P&gt;&lt;P&gt;next vValueNo;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks a lot &lt;/P&gt;&lt;P&gt;Benjamin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 11:55:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018503#M344874</guid>
      <dc:creator>benjamins</dc:creator>
      <dc:date>2016-03-07T11:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate dates for each table row</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018504#M344875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did you look at this? &lt;A href="https://community.qlik.com/message/987896"&gt;How to generate missing dates&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 12:26:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018504#M344875</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2016-03-07T12:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate dates for each table row</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018505#M344876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One of the quickest ways for your particular data set would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1457353908376727 jive_text_macro" jivemacro_uid="_1457353908376727"&gt;
&lt;P&gt;LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Id,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Date(Begin + IterNo() - 1) AS Date&lt;/P&gt;
&lt;P&gt;INLINE [&lt;/P&gt;
&lt;P&gt;Id Begin End&lt;/P&gt;
&lt;P&gt;1 2016-01-01 2016-01-09&lt;/P&gt;
&lt;P&gt;2 2016-01-01 2016-01-15&lt;/P&gt;
&lt;P&gt;3 2016-01-11 2016-01-17&lt;/P&gt;
&lt;P&gt;] ( delimiter is \t)&lt;/P&gt;
&lt;P&gt;WHILE&lt;/P&gt;
&lt;P&gt;&amp;nbsp; IterNo() &amp;lt;= Num(End) - Num(Begin) +1;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If read from an external data source it would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1457353978516590 jive_text_macro" jivemacro_uid="_1457353978516590"&gt;
&lt;P&gt;LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Id,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Date(Begin + IterNo() - 1) AS Date&lt;/P&gt;
&lt;P&gt;WHILE&lt;/P&gt;
&lt;P&gt;&amp;nbsp; IterNo() &amp;lt;= Num(End) - Num(Begin) +1;&lt;/P&gt;
&lt;P&gt;SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT Id, Begin, End FROM myTable;&lt;/P&gt;
&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14573539721937244" jivemacro_uid="_14573539721937244"&gt;
&lt;P&gt;&lt;/P&gt;

&lt;/PRE&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 12:33:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018505#M344876</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2016-03-07T12:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate dates for each table row</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018506#M344877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand that one correctly at first glance then it is about generating those dates once globally. I need to do this per table row which doesn't work out for me using a cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 12:33:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018506#M344877</guid>
      <dc:creator>benjamins</dc:creator>
      <dc:date>2016-03-07T12:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Autogenerate dates for each table row</title>
      <link>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018507#M344878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect! &lt;/P&gt;&lt;P&gt;Works like a charm.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 12:50:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Autogenerate-dates-for-each-table-row/m-p/1018507#M344878</guid>
      <dc:creator>benjamins</dc:creator>
      <dc:date>2016-03-07T12:50:51Z</dc:date>
    </item>
  </channel>
</rss>

