<?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: Historization script - working, but not plausible in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779122#M276153</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haven't be reading carefully, but maybe this helps :&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-7020"&gt;The exists issue&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Mar 2015 12:30:40 GMT</pubDate>
    <dc:creator>giakoum</dc:creator>
    <dc:date>2015-03-24T12:30:40Z</dc:date>
    <item>
      <title>Historization script - working, but not plausible</title>
      <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779119#M276150</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 a script that is intended to historize the data in one table in our database that is not historized in itself:&lt;/P&gt;&lt;P&gt;- The table holds different time_measurements for a combination of item_nr, customer and order_type&lt;/P&gt;&lt;P&gt;- Every time one such combination is assigned a new set of times, the old one is overwritten in the database&lt;/P&gt;&lt;P&gt;- All the table has is a Change_date - that is like the start_date of the validity of a new set of measurements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a historization app that is built like any other - in short, it loads an existing history, appends the data from three plants with a WHERE NOT EXÍSTS() clause on a keyfield - made up of the original combination of 3 fields and the change_date.&lt;/P&gt;&lt;P&gt;=&amp;gt; In that new table, there is only a valid_from date. A valid_until is then calculated (as either the day before the begin_date of a newer record for that same combination or a date in the far future)&lt;/P&gt;&lt;P&gt;=&amp;gt; The new table is again stored to memory, to be checked again the next day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can attach my script, it's no secret. Putting together some fake data will be more of an effort, but I can get to it this afternoon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is, the script runs daily, without any errors, but - it runs for a year now and when I look at the field 'valid_until', there is only one value - that far_future_date =&amp;gt; that means there is only one set of time_measurements for every combination, no change was ever recorded.&lt;/P&gt;&lt;P&gt;That is not very plausible. So I am searching for any potential error in the script now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me to spot potential pitfalls in there?&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 11:15:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779119#M276150</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2015-03-24T11:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Historization script - working, but not plausible</title>
      <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779120#M276151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.qlik.com/qlik-users/115174"&gt;DataNibbler&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using WHERE NOT EXISTS, this keeps on beeing validated versus the data loaded. &lt;BR /&gt;Not just the new data vs the existing data.&lt;/P&gt;&lt;P&gt;So when a new combination has been loaded this combination "suddenly" exists in the dataset and no new records will be imported.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 11:27:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779120#M276151</guid>
      <dc:creator>p_verkooijen</dc:creator>
      <dc:date>2015-03-24T11:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Historization script - working, but not plausible</title>
      <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779121#M276152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Paul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this sounds interesting. I'll have a look in the script and see if I can see what you mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are three CONCATENATEs, right?&lt;/P&gt;&lt;P&gt;In the first one, I use two different fields in this WHERE NOT EXISTS clause - the field &amp;gt; Key_change &amp;lt; that exists in the history_file and the (combination of fields making up that key) coming from the file to load.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second LOAD =&amp;gt; The field Key_change now exists in both the history and the records from plant_#1 - but the second LOAD is from another plant, so that key cannot be the same between plants, so it could only possibly be the same as in the prior history.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Third LOAD - same story.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still don't see why it doesn't work. There are quite some records coming from the first LOAD when I deactivate that clause, of course - can I maybe check that in another way, to monitor whether that clause does what it's supposed to?&lt;/P&gt;&lt;P&gt;I cannot check it against the database itself, of course, because that only ever has one record for every combination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 12:26:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779121#M276152</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2015-03-24T12:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Historization script - working, but not plausible</title>
      <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779122#M276153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haven't be reading carefully, but maybe this helps :&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-7020"&gt;The exists issue&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 12:30:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779122#M276153</guid>
      <dc:creator>giakoum</dc:creator>
      <dc:date>2015-03-24T12:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Historization script - working, but not plausible</title>
      <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779123#M276154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ioannis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that is indeed an implication that it would be very easy to fall for. I wasn't really aware of that.&lt;/P&gt;&lt;P&gt;But unfortunately, that cannot be the error in this instance. The key is made up of the three fields for which a unique set of times exists plus the date it was changed - so it is unique since any new set of times inserted for that same combination of fields would have a new change_date. So the key is necessarily unique.&lt;/P&gt;&lt;P&gt;I am just checking that, however.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 12:40:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779123#M276154</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2015-03-24T12:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Historization script - working, but not plausible</title>
      <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779124#M276155</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 now looked at the whole thing with a colleague.&lt;/P&gt;&lt;P&gt;Obviously, the historization in principle is working - we found one combination of the three principal key_fields where the change_date is different (six records), so that combination got a new set of time_measurements five times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;=&amp;gt; The issue is, we have six different "valid_from" dates (simply the recorded change_date), but only one "valid_until" date, the latter being calculated - so the error can ONLY be in that formula.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I post the formula here (in the step before that, I have sorted the whole table by those three keyfields (with no suffix) and by change_date (with the suffix desc), so the newer set of times should now be above the old one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt;IF((%ITEM_NUMBER = PREVIOUS('%ITEM_NUMBER') AND %CUSTOMER = PREVIOUS('%CUSTOMER') AND %ORDER_TYPE = PREVIOUS('%ORDER_TYPE')), (PREVIOUS('CHANGE_DATE')-1), '31.12.2100') as Valid_until&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;=&amp;gt; That seems to be right - if I have Jan. 29, 2015 and Jan 26, 2015, the newer one (from Jan 29) would be above the other.&lt;/P&gt;&lt;P&gt;=&amp;gt; That one (from Jan 29) would get Dec 31, 2100 as end_date since the formula wouldn't return TRUE.&lt;/P&gt;&lt;P&gt;=&amp;gt; The one from Jan 26 would get (Jan 29) -1 as end_date, that would be Jan 28, 2015&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only it obviously doesn't work that way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope someone can see through this. I will try myself by building in the script the different elements of that function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 13:41:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779124#M276155</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2015-03-24T13:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Historization script - working, but not plausible</title>
      <link>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779125#M276156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For whatever reason, using PREVIOUS() did not work - but using PEEK() does. Now I have six records, with the test returning TRUE five times and with six different valid_until dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will just let it run to the end before closing this thread.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2015 14:04:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Historization-script-working-but-not-plausible/m-p/779125#M276156</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2015-03-24T14:04:08Z</dc:date>
    </item>
  </channel>
</rss>

