<?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: populate the data for missing years in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/populate-the-data-for-missing-years/m-p/1849377#M1215577</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data:&lt;BR /&gt;load * inline [&lt;BR /&gt;Year, sales&lt;BR /&gt;2020,100&lt;BR /&gt;2019,200&lt;BR /&gt;2017,300&lt;BR /&gt;2016,400&lt;BR /&gt;2014,500&lt;BR /&gt;]&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//get average of all years and store in variable&lt;BR /&gt;data_avg_sales:&lt;BR /&gt;load avg(sales) as avg_sales&lt;BR /&gt;resident data;&lt;/P&gt;
&lt;P&gt;let vavgsales = peek('avg_sales', 0, 'data_avg_sales');&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//get min max years to fill in all years&lt;BR /&gt;data_min_max_year:&lt;BR /&gt;load max(Year) as maxYear&lt;BR /&gt;,min(Year) as minYear&lt;BR /&gt;resident data&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;let vmaxyear = peek('maxYear', 0, 'data_min_max_year');&lt;BR /&gt;let vminyear = peek('minYear', 0, 'data_min_max_year');&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;all_years:&lt;BR /&gt;load &lt;BR /&gt;$(vminyear) + rowno() as Year_all&lt;BR /&gt;autogenerate($(vmaxyear) - $(vminyear));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//for missing years, set sales to average sales&lt;BR /&gt;concatenate(data)&lt;BR /&gt;load &lt;BR /&gt;$(vavgsales) as sales,&lt;BR /&gt;Year_all as Year&lt;BR /&gt;resident all_years&lt;BR /&gt;where not exists(Year ,Year_all)&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//cleanup&lt;BR /&gt;drop tables all_years, data_min_max_year, data_avg_sales;&lt;/P&gt;
&lt;P&gt;exit script;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 11:25:43 GMT</pubDate>
    <dc:creator>stevejoyce</dc:creator>
    <dc:date>2021-10-20T11:25:43Z</dc:date>
    <item>
      <title>populate the data for missing years</title>
      <link>https://community.qlik.com/t5/QlikView/populate-the-data-for-missing-years/m-p/1849372#M1215576</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;i have a requirement like, i have 6 years data in that couple of years data not there, for missing years data need to populate the average of other years data.&lt;/P&gt;
&lt;P&gt;data is like below , here 2015 and 2018 are missing for that two years i need to populate the sales as 300 (average of remaining Years sales)&lt;/P&gt;
&lt;P&gt;Year, sales&lt;BR /&gt;2020,100&lt;BR /&gt;2019,200&lt;BR /&gt;2017,300&lt;BR /&gt;2016,400&lt;BR /&gt;2014,500&lt;/P&gt;
&lt;P&gt;Thanks in Advance...&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 11:10:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/populate-the-data-for-missing-years/m-p/1849372#M1215576</guid>
      <dc:creator>Navars</dc:creator>
      <dc:date>2021-10-20T11:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: populate the data for missing years</title>
      <link>https://community.qlik.com/t5/QlikView/populate-the-data-for-missing-years/m-p/1849377#M1215577</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data:&lt;BR /&gt;load * inline [&lt;BR /&gt;Year, sales&lt;BR /&gt;2020,100&lt;BR /&gt;2019,200&lt;BR /&gt;2017,300&lt;BR /&gt;2016,400&lt;BR /&gt;2014,500&lt;BR /&gt;]&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//get average of all years and store in variable&lt;BR /&gt;data_avg_sales:&lt;BR /&gt;load avg(sales) as avg_sales&lt;BR /&gt;resident data;&lt;/P&gt;
&lt;P&gt;let vavgsales = peek('avg_sales', 0, 'data_avg_sales');&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//get min max years to fill in all years&lt;BR /&gt;data_min_max_year:&lt;BR /&gt;load max(Year) as maxYear&lt;BR /&gt;,min(Year) as minYear&lt;BR /&gt;resident data&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;let vmaxyear = peek('maxYear', 0, 'data_min_max_year');&lt;BR /&gt;let vminyear = peek('minYear', 0, 'data_min_max_year');&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;all_years:&lt;BR /&gt;load &lt;BR /&gt;$(vminyear) + rowno() as Year_all&lt;BR /&gt;autogenerate($(vmaxyear) - $(vminyear));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//for missing years, set sales to average sales&lt;BR /&gt;concatenate(data)&lt;BR /&gt;load &lt;BR /&gt;$(vavgsales) as sales,&lt;BR /&gt;Year_all as Year&lt;BR /&gt;resident all_years&lt;BR /&gt;where not exists(Year ,Year_all)&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;//cleanup&lt;BR /&gt;drop tables all_years, data_min_max_year, data_avg_sales;&lt;/P&gt;
&lt;P&gt;exit script;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 11:25:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/populate-the-data-for-missing-years/m-p/1849377#M1215577</guid>
      <dc:creator>stevejoyce</dc:creator>
      <dc:date>2021-10-20T11:25:43Z</dc:date>
    </item>
  </channel>
</rss>

