<?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 Populate missing values inside a fact table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224267#M76696</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm, you could probably do something similar with a while loop.&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;[Fact Table 2]:&lt;BR /&gt;LOAD *&lt;BR /&gt; ,Key_Progressivo &amp;amp; AnnoMese as Dim_Progressivo&lt;BR /&gt;;&lt;BR /&gt;LOAD Key_Progressivo&lt;BR /&gt; ,addmonths(AnnoMese,1-iterno()) as AnnoMese&lt;BR /&gt; ,any other fields you want&lt;BR /&gt;RESIDENT FactTable&lt;BR /&gt;ORDER BY Key_Progressivo, AnnoMese&lt;BR /&gt;WHILE iterno() = 1&lt;BR /&gt; OR ( Key_Progressivo = previous(Key_Progressivo)&lt;BR /&gt; AND addmonths(AnnoMese,1-iterno()) &amp;gt; previous(AnnoMese))&lt;BR /&gt;;&lt;BR /&gt;DROP TABLE [Fact Table]&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;It's slightly different than the previous approach. Here, you'll only generate months between the first and last month for the specific Key_Progressivo. With the previous approach, you'd generate all months in the calendar. Not sure which you need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Apr 2011 23:11:37 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2011-04-20T23:11:37Z</dc:date>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224263#M76692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi to all,&lt;/P&gt;&lt;P&gt;I have a fact table where i have Product, Customer, Value and YearMonth fields, Dim_Progressivo as the key that concatenate product,customer,value,yearmonth and Key_Progressivo as the concatenate of product,customer,value.&lt;/P&gt;&lt;P&gt;I need to calculate the progressive of Value but some of the YearMonth are missing in the table. For istance I can have the product A in 201101 and 201103.&lt;/P&gt;&lt;P&gt;If I use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;rangesum((Value), if(peek('Dim_Progressivo') = Dim_Progressivo, peek('ProgressiveValue'))) as ProgressiveValue,&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;from FactTable&lt;/P&gt;&lt;P&gt;order by Key_Progressivo;&lt;/P&gt;&lt;P&gt;the result in the ProgressiveValue isn't correct.&lt;/P&gt;&lt;P&gt;The problem is that I need to add the missing YearMonth to have the correct progressivevalue calcuated. The fact table is about 10 ml records so i need to have a solution that take care of performance issues.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Thanks to all!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Apr 2011 14:23:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224263#M76692</guid>
      <dc:creator />
      <dc:date>2011-04-20T14:23:56Z</dc:date>
    </item>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224264#M76693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Aggregations in script may not be the fastest way when reloading, but it will save you some time (even lots of time) in chart rendering.&lt;/P&gt;&lt;P&gt;Check &lt;A href="http://community.qlik.com/forums/p/33501/130393.aspx#130393" target="_blank" title="Counting the number of times a word appears at the detail level"&gt;this post&lt;/A&gt; or &lt;A href="http://community.qlik.com/forums/p/43991/174933.aspx#174933" target="_blank" title="Accumulation in Script"&gt;this post&lt;/A&gt; and adapt it to your code, since it seems very similar to what you are asking for.&lt;/P&gt;&lt;P&gt;Note that Peek() returns the last loaded value, if the table is not ordered, it may return a different month and summing the wrong value.&lt;/P&gt;&lt;P&gt;Note as well that the code in the posts above uses several load steps, but that if you are able to do the SQL SELECT ordered you won't need to do that again. Although those example use RESIDENT loads, I'd recommend you to STORE the ordered table into QVD and then do the accumulation on the load of this file, if that's the case.&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Apr 2011 14:51:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224264#M76693</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-04-20T14:51:11Z</dc:date>
    </item>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224265#M76694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel,&lt;/P&gt;&lt;P&gt;unfortunatly I can't do anything on the SQL SELECT part. I have take a look on the other posts but I still have problems on creating the lines that are missing in my fact table. If you look to this example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE bgcolor="white" border="1" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR align="left"&gt;&lt;TH&gt;&lt;B&gt;Key_Progressivo&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;AnnoMese&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;sum(Importo)&lt;/B&gt;&lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR align="left"&gt;&lt;TD bgcolor="#F5F5F5"&gt;&lt;/TD&gt;&lt;TD bgcolor="#F5F5F5"&gt;&lt;/TD&gt;&lt;TD align="right" bgcolor="#F5F5F5"&gt;&lt;B&gt;39275,63&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR align="right"&gt;&lt;TD align="left" bgcolor="white"&gt;08623-00-BAN-_ns-_ns-00-SCCC301-SCCC301-D3-1030.000.100.0200-QLIK-000000093-201003&lt;/TD&gt;&lt;TD bgcolor="white"&gt;201003&lt;/TD&gt;&lt;TD bgcolor="white"&gt;10901,64&lt;/TD&gt;&lt;/TR&gt;&lt;TR align="right"&gt;&lt;TD align="left" bgcolor="white"&gt;08623-00-BAN-_ns-_ns-00-SCCC301-SCCC301-D3-1030.000.100.0200-QLIK-000000093-201004&lt;/TD&gt;&lt;TD bgcolor="white"&gt;201004&lt;/TD&gt;&lt;TD bgcolor="white"&gt;3352,71&lt;/TD&gt;&lt;/TR&gt;&lt;TR align="right"&gt;&lt;TD align="left" bgcolor="white"&gt;08623-00-BAN-_ns-_ns-00-SCCC301-SCCC301-D3-1030.000.100.0200-QLIK-000000093-201005&lt;/TD&gt;&lt;TD bgcolor="white"&gt;201005&lt;/TD&gt;&lt;TD bgcolor="white"&gt;1258,18&lt;/TD&gt;&lt;/TR&gt;&lt;TR align="right"&gt;&lt;TD align="left" bgcolor="white"&gt;08623-00-BAN-_ns-_ns-00-SCCC301-SCCC301-D3-1030.000.100.0200-QLIK-000000093-201007&lt;/TD&gt;&lt;TD bgcolor="white"&gt;201007&lt;/TD&gt;&lt;TD bgcolor="white"&gt;3742,58&lt;/TD&gt;&lt;/TR&gt;&lt;TR align="right"&gt;&lt;TD align="left" bgcolor="white"&gt;08623-00-BAN-_ns-_ns-00-SCCC301-SCCC301-D3-1030.000.100.0200-QLIK-000000093-201009&lt;/TD&gt;&lt;TD bgcolor="white"&gt;201009&lt;/TD&gt;&lt;TD bgcolor="white"&gt;179,72&lt;/TD&gt;&lt;/TR&gt;&lt;TR align="right"&gt;&lt;TD align="left" bgcolor="white"&gt;08623-00-BAN-_ns-_ns-00-SCCC301-SCCC301-D3-1030.000.100.0200-QLIK-000000093-201012&lt;/TD&gt;&lt;TD bgcolor="white"&gt;201012&lt;/TD&gt;&lt;TD bgcolor="white"&gt;1673,86&lt;/TD&gt;&lt;/TR&gt;&lt;TR align="right"&gt;&lt;TD align="left" bgcolor="white"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD bgcolor="white"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD bgcolor="white"&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;you can see that the 201006 is missing. I need to add a line to my fact table with 201008 and Importo = 0 otherwise some additional things will not work as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Apr 2011 21:58:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224265#M76694</guid>
      <dc:creator />
      <dc:date>2011-04-20T21:58:35Z</dc:date>
    </item>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224266#M76695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So for EVERY value of Key_Progressivo, you want EVERY month in your table? Perhaps something like this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;[All]:&lt;BR /&gt;LOAD text(fieldvalue('Key_Progressivo',iterno())) as Key_Progressivo&lt;BR /&gt;AUTOGENERATE 1&lt;BR /&gt;WHILE len(fieldvalue('Key_Progressivo',iterno()))&lt;BR /&gt;;&lt;BR /&gt;LEFT JOIN ([All])&lt;BR /&gt;LOAD DISTINCT AnnoMese&lt;BR /&gt;RESIDENT [Calendar]&lt;BR /&gt;;&lt;BR /&gt;LEFT JOIN ([All])&lt;BR /&gt;LOAD *&lt;BR /&gt;,Key_Progressivo &amp;amp; AnnoMese as Dim_Progressivo // or however you define Dim_Progressivo&lt;BR /&gt;RESIDENT [All]&lt;BR /&gt;;&lt;BR /&gt;OUTER JOIN ([Fact Table])&lt;BR /&gt;LOAD *&lt;BR /&gt;RESIDENT [All]&lt;BR /&gt;;&lt;BR /&gt;DROP TABLE [All]&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;There might be a simpler way. That also leaves Importo=null for the added months. I don't know if that's a problem, but an extra pass through can set those nulls to 0 if need be.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Apr 2011 22:40:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224266#M76695</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-04-20T22:40:45Z</dc:date>
    </item>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224267#M76696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm, you could probably do something similar with a while loop.&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;[Fact Table 2]:&lt;BR /&gt;LOAD *&lt;BR /&gt; ,Key_Progressivo &amp;amp; AnnoMese as Dim_Progressivo&lt;BR /&gt;;&lt;BR /&gt;LOAD Key_Progressivo&lt;BR /&gt; ,addmonths(AnnoMese,1-iterno()) as AnnoMese&lt;BR /&gt; ,any other fields you want&lt;BR /&gt;RESIDENT FactTable&lt;BR /&gt;ORDER BY Key_Progressivo, AnnoMese&lt;BR /&gt;WHILE iterno() = 1&lt;BR /&gt; OR ( Key_Progressivo = previous(Key_Progressivo)&lt;BR /&gt; AND addmonths(AnnoMese,1-iterno()) &amp;gt; previous(AnnoMese))&lt;BR /&gt;;&lt;BR /&gt;DROP TABLE [Fact Table]&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;It's slightly different than the previous approach. Here, you'll only generate months between the first and last month for the specific Key_Progressivo. With the previous approach, you'd generate all months in the calendar. Not sure which you need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Apr 2011 23:11:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224267#M76696</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-04-20T23:11:37Z</dc:date>
    </item>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224268#M76697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;thank you, exactly what I was looking for, only the missing months from the first and the last one.&lt;/P&gt;&lt;P&gt;I tried your solution but I get exactly the same records, probably&lt;/P&gt;&lt;P&gt;I attach the qvw and the qvd where you can see the results.&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Andrea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2011 08:28:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224268#M76697</guid>
      <dc:creator />
      <dc:date>2011-04-21T08:28:52Z</dc:date>
    </item>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224269#M76698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;BR /&gt;danielato.a wrote: I tried your solution but I get exactly the same records&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Several problems.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I assumed that AnnoMese was a date field with a format of YYYYMM, not just a number. I recommend changing it in the QVD.&lt;/LI&gt;&lt;LI&gt;You'd said that Key_Progressivo was "the concatenate of product,customer,value". Instead, it also includes the YearMonth. It appears that Key_Progressivo_SenzaAnnoMese is actually the one that doesn't include the YearMonth. So we'd need to use that instead.&lt;/LI&gt;&lt;LI&gt;Previous(AnnoMese) wasn't behaving as I expected in a WHILE loop, so I had to create a new field, PreviousAnnoMese, before going into the WHILE loop. I probably just messed something up and the new field isn't necessary, but I'm not seeing it.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;See attached. Script below.&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;[Fact Table]:&lt;BR /&gt;LOAD&lt;BR /&gt; Key_Progressivo_SenzaAnnoMese&lt;BR /&gt;,date(date#(AnnoMese,'YYYYMM'),'YYYYMM') as AnnoMese&lt;BR /&gt;,peek('AnnoMese') as PreviousAnnoMese&lt;BR /&gt;,Importo&lt;BR /&gt;FROM andrea.qvd (qvd)&lt;BR /&gt;;&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;[Fact Table 2]:&lt;BR /&gt;LOAD *&lt;BR /&gt; ,Key_Progressivo_SenzaAnnoMese &amp;amp; date(AnnoMese,'YYYYMM') as Key_Progressivo&lt;BR /&gt;;&lt;BR /&gt;LOAD Key_Progressivo_SenzaAnnoMese&lt;BR /&gt; ,addmonths(AnnoMese,1-iterno()) as AnnoMese&lt;BR /&gt; ,Importo&lt;BR /&gt;RESIDENT [Fact Table]&lt;BR /&gt;WHILE iterno() = 1&lt;BR /&gt; OR ( Key_Progressivo_SenzaAnnoMese = previous(Key_Progressivo_SenzaAnnoMese)&lt;BR /&gt; AND addmonths(AnnoMese,1-iterno()) &amp;gt; PreviousAnnoMese)&lt;BR /&gt;ORDER BY Key_Progressivo_SenzaAnnoMese, AnnoMese&lt;BR /&gt;;&lt;BR /&gt;DROP TABLE [Fact Table]&lt;BR /&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2011 18:27:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224269#M76698</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-04-21T18:27:25Z</dc:date>
    </item>
    <item>
      <title>Populate missing values inside a fact table</title>
      <link>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224270#M76699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;perfect! Tomorrow morning I will do the test on the live environment within my 10 ML records of fact table to see the performance. I will let you know.&lt;/P&gt;&lt;P&gt;Thanks a lot for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2011 23:18:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Populate-missing-values-inside-a-fact-table/m-p/224270#M76699</guid>
      <dc:creator />
      <dc:date>2011-04-21T23:18:21Z</dc:date>
    </item>
  </channel>
</rss>

