<?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: Calculate interest on interest in script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844071#M296482</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;one solution could be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_163681_Pic1.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/86350_QlikCommunity_Thread_163681_Pic1.JPG" style="height: 358px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_163681_Pic2.JPG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/86354_QlikCommunity_Thread_163681_Pic2.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14314729392911439" jivemacro_uid="_14314729392911439"&gt;
&lt;P&gt;tabTestData:&lt;/P&gt;
&lt;P&gt;LOAD Date(Today()-1000+IterNo()) as Date,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num(Round((Rand()*0.2)+0.9,0.01),'0.00') as Interest&lt;/P&gt;
&lt;P&gt;AutoGenerate 1&lt;/P&gt;
&lt;P&gt;While IterNo()&amp;lt;=1000;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;tabData:&lt;/P&gt;
&lt;P&gt;LOAD *,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IoI1/IoI2 as InterestOnInterest;&lt;/P&gt;
&lt;P&gt;LOAD Date,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interest,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interest*Alt(Peek(IoI1),1) as IoI1, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alt(Peek(Interest,-365),1)*Alt(Peek(IoI2),1) as IoI2&lt;/P&gt;
&lt;P&gt;Resident tabTestData;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;DROP Table tabTestData;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(just drop the auxiliary fields IoI1 and IoI2 if not needed)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 May 2015 23:23:26 GMT</pubDate>
    <dc:creator>MarcoWedel</dc:creator>
    <dc:date>2015-05-12T23:23:26Z</dc:date>
    <item>
      <title>Calculate interest on interest in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844068#M296479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there an easy way to calculate interest on interest in the script, per date and aggregated over a set time period.&lt;/P&gt;&lt;P&gt;The interest or return will differ for each date and is shown as a per cent where below 1 is negative interest and above 1 is positive interest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="249" style="border: 1px solid rgb(0, 0, 0); width: 375px; height: 241px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Interest&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-01&lt;/TD&gt;0,99&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-02&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0,95&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-03&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1,1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-04&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1,04&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-05&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1,01&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-06&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-07&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0,98&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-08&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0,96&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015-01-09&lt;/TD&gt;0,99&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;For each row the accumulated interest on interest should then be calculated. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;In a chart I am using I use&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;(exp&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;log&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Performance&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; )))&lt;/SPAN&gt;&lt;STRONG style=": ; color: #ff8000; font-size: 8pt; text-decoration: underline;"&gt;) &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Now, I want to precalculate this so every date get its accumulated return on return (interest on interest) for a set time period. In reality my time period will be one year, but in this example we can use today -2 days.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;So in the above example 2015-01-03 should get 1,03455 ( 0,99 * 0,95 * 1,1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;while 2015-01-04 should get&amp;nbsp; 1,0868&amp;nbsp;&amp;nbsp; (0,95 * 1,1 * 1,04).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2015 12:45:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844068#M296479</guid>
      <dc:creator />
      <dc:date>2015-05-12T12:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate interest on interest in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844069#M296480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure - you will have to create a calculated field in your LOAD statement. This should use the Peek()-function to refer to the last loaded value. You add that to the current interest for the date and row being read. You will have to make sure you make the LOAD in sorted order by ascending date...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2015 15:46:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844069#M296480</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-05-12T15:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate interest on interest in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844070#M296481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InterestDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interest,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If( RecNo() = 1 , 1 , Peek('AccInt') ) * Interest AS AccInt&lt;/P&gt;&lt;P&gt;RESIDENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateAndInterestTable&lt;/P&gt;&lt;P&gt;ORDER BY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2015 16:18:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844070#M296481</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-05-12T16:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate interest on interest in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844071#M296482</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;one solution could be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_163681_Pic1.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/86350_QlikCommunity_Thread_163681_Pic1.JPG" style="height: 358px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_163681_Pic2.JPG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/86354_QlikCommunity_Thread_163681_Pic2.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14314729392911439" jivemacro_uid="_14314729392911439"&gt;
&lt;P&gt;tabTestData:&lt;/P&gt;
&lt;P&gt;LOAD Date(Today()-1000+IterNo()) as Date,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num(Round((Rand()*0.2)+0.9,0.01),'0.00') as Interest&lt;/P&gt;
&lt;P&gt;AutoGenerate 1&lt;/P&gt;
&lt;P&gt;While IterNo()&amp;lt;=1000;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;tabData:&lt;/P&gt;
&lt;P&gt;LOAD *,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IoI1/IoI2 as InterestOnInterest;&lt;/P&gt;
&lt;P&gt;LOAD Date,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interest,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interest*Alt(Peek(IoI1),1) as IoI1, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alt(Peek(Interest,-365),1)*Alt(Peek(IoI2),1) as IoI2&lt;/P&gt;
&lt;P&gt;Resident tabTestData;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;DROP Table tabTestData;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(just drop the auxiliary fields IoI1 and IoI2 if not needed)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2015 23:23:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844071#M296482</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2015-05-12T23:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate interest on interest in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844072#M296483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Marco. That seems to work fine. In my solution I have a great number of stocks to calculate this and different scenarios, but I guess that can be handled by grouping and sorting.&lt;/P&gt;&lt;P&gt;I also have problems with the -365 as I done have interests on all dates, any hints there or do I have to fill out the empty dates with interest of 1?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As of Petters solution, I think that will work to calculate interest over time, but it does not take the 365 day cap into account.&lt;/P&gt;&lt;P&gt;Thanks for the suggestion though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 08:33:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-interest-on-interest-in-script/m-p/844072#M296483</guid>
      <dc:creator />
      <dc:date>2015-05-13T08:33:34Z</dc:date>
    </item>
  </channel>
</rss>

