<?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: How to loop through a dataset and use previously calculated values? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998989#M647790</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;Hey,&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;thanks for your reply. Its not necessary to do the calculation on the&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;script level. Well, for no reason I tend to do a lot of things in the script...&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;I create the ID from the articlenumber and the calendarweek, so that it is&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;a unique one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 Oct 2015 11:18:06 GMT</pubDate>
    <dc:creator>Milo2009</dc:creator>
    <dc:date>2015-10-17T11:18:06Z</dc:date>
    <item>
      <title>How to loop through a dataset and use previously calculated values?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998986#M647786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;although I'm getting familar with QV and scripting I now have a question regarding Loops and Calculations in the script.&lt;/P&gt;&lt;P&gt;I want to perform a XYZ-Analysys. Therefore I have to compute some values....&lt;/P&gt;&lt;P&gt;Until now I do this steps in my script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SOURCE:&lt;/P&gt;&lt;P&gt;LOAD ARTNR,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WEEK,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YEAR,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WEEK &amp;amp;'_'&amp;amp; YEAR AS WEEK_YEAR,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DAN &amp;amp;'_'&amp;amp; WEEK &amp;amp;'_'&amp;amp; YEAR AS ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORECAST,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SALES&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[..\SOURCEDATA\XYZANALSYSE\SALES.xlsx]&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is SalesJan2014)&lt;/P&gt;&lt;P&gt;WHERE YEAR = 2014;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET $(SQ) = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;LET $(SF) = 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For each ID in SOURCE&lt;/P&gt;&lt;P&gt;LEFT JOIN (SOURCE)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5*($(SQ)+($(SF)*FABS(1-(SALES/FORECAST)))) AS COEFFICIENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RESIDENT SOURCE;&lt;/P&gt;&lt;P&gt;NEXT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;So what I want to calculate is the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SQ&lt;SPAN style="font-size: 8pt;"&gt;t&lt;/SPAN&gt; =&amp;nbsp; 0.5*($(SQ&lt;SPAN style="font-size: 8pt;"&gt;t-1&lt;/SPAN&gt;)+($(SF)*FABS(1-(SALES/FORECAST))))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the first period (calendarweek 1) SQ&lt;SPAN style="font-size: 8pt;"&gt;t-1 &lt;SPAN style="font-size: 10pt;"&gt;vanishes the value 0 as set above the loop. As a result of the formula I get a value for SQ&lt;SPAN style="font-size: 8pt;"&gt;1 &lt;SPAN style="font-size: 10pt;"&gt;for the first calendarweek. Now I want to calculate SQ&lt;SPAN style="font-size: 8pt;"&gt;2&lt;/SPAN&gt; for the calendarweek 2. Now my SQ&lt;SPAN style="font-size: 8pt;"&gt;t-1&lt;/SPAN&gt; should vanish the result of the formula from the previous period (calendarweek 1). This I want to do for every week in a year. I always use the result from the previous period in the calculation for the actual period.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;But I do not know, how to do this in a Script:/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any ideas &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Oct 2015 18:08:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998986#M647786</guid>
      <dc:creator>Milo2009</dc:creator>
      <dc:date>2015-10-16T18:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a dataset and use previously calculated values?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998987#M647787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a necessary to pre calculate on the script level ? If not please do these calculation on UI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, Please share some sample data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Oct 2015 20:21:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998987#M647787</guid>
      <dc:creator />
      <dc:date>2015-10-16T20:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a dataset and use previously calculated values?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998988#M647788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;more Question:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is ID is a unique key on the source data set ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Oct 2015 20:25:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998988#M647788</guid>
      <dc:creator />
      <dc:date>2015-10-16T20:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a dataset and use previously calculated values?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998989#M647790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;Hey,&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;thanks for your reply. Its not necessary to do the calculation on the&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;script level. Well, for no reason I tend to do a lot of things in the script...&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;I create the ID from the articlenumber and the calendarweek, so that it is&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;a unique one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Oct 2015 11:18:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-loop-through-a-dataset-and-use-previously-calculated/m-p/998989#M647790</guid>
      <dc:creator>Milo2009</dc:creator>
      <dc:date>2015-10-17T11:18:06Z</dc:date>
    </item>
  </channel>
</rss>

