<?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 Data based on Start and End Date in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-Data-based-on-Start-and-End-Date/m-p/2052994#M1223051</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am currently trying to explode my table so that I get a value for every date.&lt;/P&gt;
&lt;P&gt;Example:&lt;BR /&gt;LOAD * INLINE [Product,Customer,Price,Cost,Date&lt;BR /&gt;4444,123,1.58025,1.55895,2022-10-10&lt;BR /&gt;4444,123,1.67019,1.64889,2022-10-19&lt;BR /&gt;4444,123,1.61818,1.59688,2022-10-27&lt;BR /&gt;4444,123,1.53070,1.50940,2022-11-07&lt;BR /&gt;4444,123,1.44931,1.41831,2022-11-11&lt;BR /&gt;4444,123,1.38543,1.35443,2022-11-23&lt;BR /&gt;4444,123,1.34208,1.32078,2022-11-30&lt;BR /&gt;4444,123,1.26694,1.23594,2022-12-09&lt;BR /&gt;4444,123,1.29378,1.27248,2022-12-15&lt;BR /&gt;4444,123,1.30395,1.28265,2022-12-28&lt;BR /&gt;5555,243,1.58025,1.55895,2022-10-10&lt;BR /&gt;5555,243,1.67019,1.64889,2022-10-19&lt;BR /&gt;5555,243,1.61818,1.59688,2022-10-27&lt;BR /&gt;5555,243,1.53070,1.50940,2022-11-07&lt;BR /&gt;5555,243,1.44931,1.41831,2022-11-11&lt;BR /&gt;5555,243,1.38543,1.35443,2022-11-23&lt;BR /&gt;5555,243,1.34208,1.32078,2022-11-30&lt;BR /&gt;5555,243,1.26694,1.23594,2022-12-09&lt;BR /&gt;5555,243,1.29378,1.27248,2022-12-15&lt;BR /&gt;5555,243,1.30395,1.28265,2022-12-28&lt;BR /&gt;]&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;My idea was to first create a StartDate and EndDate per Row so for example if we would look at:&lt;/P&gt;
&lt;P&gt;Product,Customer,Price,Cost,Datetime&lt;/P&gt;
&lt;P&gt;4444,123,1.61818,1.59688,2022-10-27&lt;BR /&gt;4444,123,1.53070,1.50940,2022-11-07&lt;/P&gt;
&lt;P&gt;I would want to create a field ValidFrom 2022/10/27 and for this one the ValidTo would be the 2022/11/07 -1 day so 2022/11/06.&lt;/P&gt;
&lt;P&gt;Product,Customer,Price,Cost,Datetime,ValidFrom,Validto&lt;/P&gt;
&lt;P&gt;4444,123,1.61818,1.59688,2022-10-27,2022-10-27,2022-11-06&lt;BR /&gt;4444,123,1.53070,1.50940,2022-11-07,2022-11-07,2022-11-10&lt;/P&gt;
&lt;P&gt;In SQL I can achieve this with the Lead function, how do I achieve this in the QV Script?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;After this I would use want to explode this table with all possible dates for the year 2022 for example. Then I thought using IntervalMatch and ValidFrom + ValidTo dates I can match the correct Price and Cost to those dates. For example for 2022/10/31 I also want to have Price = 1.6181 and Cost = 1.59688.&lt;/P&gt;
&lt;P&gt;So in the end I have a table with all Price and Cost per Product for every date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is greatly appreciated! Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 15:00:33 GMT</pubDate>
    <dc:creator>luca7</dc:creator>
    <dc:date>2023-03-24T15:00:33Z</dc:date>
    <item>
      <title>Create Data based on Start and End Date</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Data-based-on-Start-and-End-Date/m-p/2052994#M1223051</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am currently trying to explode my table so that I get a value for every date.&lt;/P&gt;
&lt;P&gt;Example:&lt;BR /&gt;LOAD * INLINE [Product,Customer,Price,Cost,Date&lt;BR /&gt;4444,123,1.58025,1.55895,2022-10-10&lt;BR /&gt;4444,123,1.67019,1.64889,2022-10-19&lt;BR /&gt;4444,123,1.61818,1.59688,2022-10-27&lt;BR /&gt;4444,123,1.53070,1.50940,2022-11-07&lt;BR /&gt;4444,123,1.44931,1.41831,2022-11-11&lt;BR /&gt;4444,123,1.38543,1.35443,2022-11-23&lt;BR /&gt;4444,123,1.34208,1.32078,2022-11-30&lt;BR /&gt;4444,123,1.26694,1.23594,2022-12-09&lt;BR /&gt;4444,123,1.29378,1.27248,2022-12-15&lt;BR /&gt;4444,123,1.30395,1.28265,2022-12-28&lt;BR /&gt;5555,243,1.58025,1.55895,2022-10-10&lt;BR /&gt;5555,243,1.67019,1.64889,2022-10-19&lt;BR /&gt;5555,243,1.61818,1.59688,2022-10-27&lt;BR /&gt;5555,243,1.53070,1.50940,2022-11-07&lt;BR /&gt;5555,243,1.44931,1.41831,2022-11-11&lt;BR /&gt;5555,243,1.38543,1.35443,2022-11-23&lt;BR /&gt;5555,243,1.34208,1.32078,2022-11-30&lt;BR /&gt;5555,243,1.26694,1.23594,2022-12-09&lt;BR /&gt;5555,243,1.29378,1.27248,2022-12-15&lt;BR /&gt;5555,243,1.30395,1.28265,2022-12-28&lt;BR /&gt;]&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;My idea was to first create a StartDate and EndDate per Row so for example if we would look at:&lt;/P&gt;
&lt;P&gt;Product,Customer,Price,Cost,Datetime&lt;/P&gt;
&lt;P&gt;4444,123,1.61818,1.59688,2022-10-27&lt;BR /&gt;4444,123,1.53070,1.50940,2022-11-07&lt;/P&gt;
&lt;P&gt;I would want to create a field ValidFrom 2022/10/27 and for this one the ValidTo would be the 2022/11/07 -1 day so 2022/11/06.&lt;/P&gt;
&lt;P&gt;Product,Customer,Price,Cost,Datetime,ValidFrom,Validto&lt;/P&gt;
&lt;P&gt;4444,123,1.61818,1.59688,2022-10-27,2022-10-27,2022-11-06&lt;BR /&gt;4444,123,1.53070,1.50940,2022-11-07,2022-11-07,2022-11-10&lt;/P&gt;
&lt;P&gt;In SQL I can achieve this with the Lead function, how do I achieve this in the QV Script?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;After this I would use want to explode this table with all possible dates for the year 2022 for example. Then I thought using IntervalMatch and ValidFrom + ValidTo dates I can match the correct Price and Cost to those dates. For example for 2022/10/31 I also want to have Price = 1.6181 and Cost = 1.59688.&lt;/P&gt;
&lt;P&gt;So in the end I have a table with all Price and Cost per Product for every date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is greatly appreciated! Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 15:00:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Data-based-on-Start-and-End-Date/m-p/2052994#M1223051</guid>
      <dc:creator>luca7</dc:creator>
      <dc:date>2023-03-24T15:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create Data based on Start and End Date</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Data-based-on-Start-and-End-Date/m-p/2053048#M1223054</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Design/Creating-Reference-Dates-for-Intervals/ba-p/1463944" target="_blank"&gt;https://community.qlik.com/t5/Design/Creating-Reference-Dates-for-Intervals/ba-p/1463944&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 17:27:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Data-based-on-Start-and-End-Date/m-p/2053048#M1223054</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2023-03-24T17:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create Data based on Start and End Date</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Data-based-on-Start-and-End-Date/m-p/2053066#M1223055</link>
      <description>&lt;P&gt;one example&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarcoWedel_0-1679680881612.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/103462i7841BC89245A3A9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="MarcoWedel_0-1679680881612.png" alt="MarcoWedel_0-1679680881612.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarcoWedel_1-1679681023310.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/103463i1CA4E9C7C4F067A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="MarcoWedel_1-1679681023310.png" alt="MarcoWedel_1-1679681023310.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Example:
LOAD * INLINE [Product,Customer,Price,Cost,Date
4444,123,1.58025,1.55895,2022-10-10
4444,123,1.67019,1.64889,2022-10-19
4444,123,1.61818,1.59688,2022-10-27
4444,123,1.53070,1.50940,2022-11-07
4444,123,1.44931,1.41831,2022-11-11
4444,123,1.38543,1.35443,2022-11-23
4444,123,1.34208,1.32078,2022-11-30
4444,123,1.26694,1.23594,2022-12-09
4444,123,1.29378,1.27248,2022-12-15
4444,123,1.30395,1.28265,2022-12-28
5555,243,2.58025,2.55895,2022-10-10
5555,243,2.67019,2.64889,2022-10-19
5555,243,2.61818,2.59688,2022-10-27
5555,243,2.53070,2.50940,2022-11-07
5555,243,2.44931,2.41831,2022-11-11
5555,243,2.38543,2.35443,2022-11-23
5555,243,2.34208,2.32078,2022-11-30
5555,243,2.26694,2.23594,2022-12-09
5555,243,2.29378,2.27248,2022-12-15
5555,243,2.30395,2.28265,2022-12-28
]
;

Temp:
LOAD *,
     Date as ValidFrom,
     Date(If(Product=Previous(Product) and Customer=Previous(Customer),Previous(Date)-1,DayStart(YearEnd(Date))),'YYYY-MM-DD') as ValidTo
Resident Example
Order By Product,Customer,Date desc;

NoConcatenate
Result:
LOAD Product,
     Customer,
     Price,
     Cost,
     ValidFrom,
     ValidTo,
     Date(ValidFrom+IterNo()-1,'YYYY-MM-DD') as Date
Resident Temp
While ValidFrom+IterNo()-1 &amp;lt;= ValidTo
Order By Product,Customer,Date;

DROP Tables Example,Temp;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 18:04:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Data-based-on-Start-and-End-Date/m-p/2053066#M1223055</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2023-03-24T18:04:13Z</dc:date>
    </item>
  </channel>
</rss>

