<?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: Overwriting Rows and Incremental Load in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020470#M637822</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The old record will be "rewritten" because of the "WHERE not exists" clause.&amp;nbsp; It will not load the old record from the QVD, so it will be "rewritten" by what was pulled from the database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Apr 2016 15:38:50 GMT</pubDate>
    <dc:creator>Nicole-Smith</dc:creator>
    <dc:date>2016-04-27T15:38:50Z</dc:date>
    <item>
      <title>Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020467#M637819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following table which will be refreshed daily and will contain years of daily data which means ~30 million records:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table1:&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;SKU&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Day&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Key&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Qty&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;01/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;A01/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;02/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;A02/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;03/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;A03/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to load all of the historical data from my database into a QVD and then everyday take the last 3 days of data from my database and add any new records (which I can determine by the Key field) and then if a record comes in during the last 3 days load that already has an existing key in the historical QVD I would like to overwrite that record. I need to do this as the data in the column Qty can change historically over the last 3 days. Can anyone help with this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2016 10:57:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020467#M637819</guid>
      <dc:creator>rileymd88</dc:creator>
      <dc:date>2016-04-26T10:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020468#M637820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is some "pseudo" code to hopefully get you started...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Check if QVD exists, if not load all history from DB */&lt;/P&gt;&lt;P&gt;IF FileTime(YourQVD.qvd)&amp;gt;0 THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Load last 3 days from DB */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vMinDate = date(today()-3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YourTable:&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM YourDatabaseTable&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE YourDateField &amp;gt;= $(vMinDate);&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Load only things not updated from QVD */&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CONCATENATE (YourTable)&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD *&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM YourQVD.qvd&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE not exists(YourKeyField);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Load everything from database */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YourTable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM YourDatabaseTable;&lt;/P&gt;&lt;P&gt;ENDIF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STORE * FROM YourTable INTO YourQVD.qvd (qvd);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2016 17:15:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020468#M637820</guid>
      <dc:creator>Nicole-Smith</dc:creator>
      <dc:date>2016-04-26T17:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020469#M637821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This works fine for my first case of only adding the new records, however how do I deal with records that need to be overwritten? In this case you could imagine my key of SKU&amp;amp;Day would exist in the stored QVD already but the Qty would be different and therefore I would need to take this record and add it into my stored QVD and ensure the old record is overwritten with the new one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2016 11:15:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020469#M637821</guid>
      <dc:creator>rileymd88</dc:creator>
      <dc:date>2016-04-27T11:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020470#M637822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The old record will be "rewritten" because of the "WHERE not exists" clause.&amp;nbsp; It will not load the old record from the QVD, so it will be "rewritten" by what was pulled from the database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2016 15:38:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020470#M637822</guid>
      <dc:creator>Nicole-Smith</dc:creator>
      <dc:date>2016-04-27T15:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020471#M637823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you I read too quickly the first time around this is perfect. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2016 15:47:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1020471#M637823</guid>
      <dc:creator>rileymd88</dc:creator>
      <dc:date>2016-04-27T15:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1536050#M637824</link>
      <description>&lt;P&gt;Hey Nicole,really nice solution.But,I need your help in implementing your solution for our case.&lt;/P&gt;&lt;P&gt;In our case,the historical data would be loaded into a QVD as a one-time activity and we will get "last 30 days" feed every day.&lt;/P&gt;&lt;P&gt;For example,Let us assume our historical data contains data from Jan 1st 2016 to Dec 27th,2018.&lt;/P&gt;&lt;P&gt;On Jan 27th,2019 the API feed&amp;nbsp;would give us data for the time period &lt;STRONG&gt;Dec 28th,2018 to Jan 27th,2019&lt;/STRONG&gt;.On Jan 28th,it would be &lt;STRONG&gt;Dec 29th to Jan 28th&lt;/STRONG&gt; data.How do we make sure we are not missing out on &lt;STRONG&gt;Dec 28th&lt;/STRONG&gt; data and that we are permanently storing the preceding day's data(28th Dec in this case) along with the historical data at one place?&lt;/P&gt;&lt;P&gt;The problem is,if we &lt;STRONG&gt;store x in abc.qvd&lt;/STRONG&gt; and then&amp;nbsp;perform &lt;STRONG&gt;store y in abc.qvd&lt;/STRONG&gt;,it will only contain y in the abc.qvd and not both x and y.&lt;/P&gt;&lt;P&gt;Your help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 15:53:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1536050#M637824</guid>
      <dc:creator>jhstrange</dc:creator>
      <dc:date>2019-01-28T15:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1536698#M637826</link>
      <description>&lt;P&gt;You load your new data from wherever you're getting it from, load the old data from the QVD (concatenating it to the new data), and then store in the QVD.&lt;/P&gt;&lt;P&gt;Something like this:&lt;/P&gt;&lt;PRE&gt;New_Data:
SELECT Date, Field1, Field2, Field3...
FROM YourSource;

Min_Date:
LOAD MIN(Date) AS Min_Date
RESIDENT New_Data;
LET vMinDate = PEEK('Min_Date', 0, 'Min_Date');
DROP TABLE Min_Date;

CONCATENATE (New_Data)
LOAD Date, Field1, Field2, Field3...
FROM YourQVD
WHERE Date &amp;lt; $(vMinDate);

STORE * FROM New_DATA INTO YourQVD;&lt;/PRE&gt;&lt;P&gt;If the concatenate piece is taking too long to load, you can either:&lt;BR /&gt;1) Use an exists clause instead of the &amp;lt; comparison in order to optimize the load&lt;BR /&gt;2) Load the entire thing&amp;nbsp; without the &amp;lt; comparison into a temp table and then have a second query concatenate it using the &amp;lt; comparison&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 17:54:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1536698#M637826</guid>
      <dc:creator>Nicole-Smith</dc:creator>
      <dc:date>2019-01-29T17:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1536750#M637828</link>
      <description>&lt;P&gt;&amp;nbsp;Thanks a lot Nicole!!&lt;/P&gt;&lt;P&gt;An example scenario:Assuming 'YourQVD' contains data until 25th Jan,2019.On the 26th Feb,the 30-day pull('YourSource') would retrieve 28th Jan to 26th Feb records.So,we would be missing out on 26th Jan and 27th Jan records.&lt;/P&gt;&lt;P&gt;Maybe the only thing with this implementation is that the historical data needs to be uploaded to 'YourQVD' once every 30 days as&amp;nbsp;'YourSource' retrieves only the last 30 days data.This way entries for any dates are not missed.&lt;/P&gt;&lt;P&gt;Have I understood it right Nicole?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 19:19:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1536750#M637828</guid>
      <dc:creator>jhstrange</dc:creator>
      <dc:date>2019-01-29T19:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Overwriting Rows and Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1537356#M637830</link>
      <description>&lt;P&gt;You could run the code daily.&amp;nbsp; Added comments inline below to explain what's happening.&amp;nbsp; You shouldn't be missing any data using this.&lt;/P&gt;&lt;PRE&gt;//Grab all of the new data out of the database or wherever it's coming from
New_Data:
SELECT Date, Field1, Field2, Field3...
FROM YourSource;

//Find the earliest date in the new data
Min_Date:
LOAD MIN(Date) AS Min_Date
RESIDENT New_Data;
LET vMinDate = PEEK('Min_Date', 0, 'Min_Date');
DROP TABLE Min_Date;

//Pull anything before the earliest date in the new data from the QVD (so if it's not in the new data, then pull it from the QVD)
CONCATENATE (New_Data)
LOAD Date, Field1, Field2, Field3...
FROM YourQVD
WHERE Date &amp;lt; $(vMinDate);

//Store all old and new data (because they are all in one table now) into a QVD
STORE * FROM New_Data INTO YourQVD;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Jan 2019 17:05:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Overwriting-Rows-and-Incremental-Load/m-p/1537356#M637830</guid>
      <dc:creator>Nicole-Smith</dc:creator>
      <dc:date>2019-01-30T17:05:30Z</dc:date>
    </item>
  </channel>
</rss>

