<?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: Re: Accumulation in script problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615931#M227123</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes HIC.&lt;BR /&gt;But we shouldn't consider the posting date.&lt;BR /&gt;Some peace of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13983650479916007" jivemacro_uid="_13983650479916007"&gt;
&lt;P&gt;[tmp]:&lt;/P&gt;
&lt;P&gt;LOAD * INLINE [&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 'Posting Date','Location Code', 'Item No_', 'Variant Code', 'Entry Type',Quantity&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01.01.2013, 1, 1, 1, BYE, 10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02.01.2013, 1, 1, 1, BYE, 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02.01.2013, 1, 1, 1, SELL, -3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03.01.2013, 2, 1, 1, BYE, 20&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03.01.2013, 2, 1, 1, SELL, -10&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;tmp2:&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;/P&gt;
&lt;P&gt;LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; RecNo() as Rec,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Posting Date],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Location Code],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Item No_],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Variant Code],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Entry Type],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Quantity,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Num(If([Posting Date]&amp;nbsp; = Peek([Posting Date])&amp;nbsp; and [Location Code] = Peek([Location Code]) and&amp;nbsp; [Item No_] = Peek([Item No_]) and [Variant Code]&amp;nbsp; = Peek([Variant Code]), RangeSum(Peek('QTY_Accum'), Quantity), Quantity ))) as QTY_Accum,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Num(IF([Location Code] = Peek([Location Code]) and&amp;nbsp; [Item No_] = Peek([Item No_]) and [Variant Code]&amp;nbsp; = Peek([Variant Code]),NumSum(Peek('QTY_Accum2'),Num(Quantity)),Num(Quantity))) as QTY_Accum2&lt;/P&gt;
&lt;P&gt;Resident tmp&lt;/P&gt;
&lt;P&gt;Order by [Posting Date] asc,[Location Code] asc,[Item No_] asc,[Variant Code] asc;&lt;/P&gt;
&lt;P&gt;Drop Table tmp;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like we shouldn't consider date in condition of accumulation.&lt;/P&gt;&lt;P&gt;Any way thnx a lot.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;eek('QTY_A&lt;/SPAN&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;eek('QTY_A&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Apr 2014 18:39:11 GMT</pubDate>
    <dc:creator>lylererger</dc:creator>
    <dc:date>2014-04-24T18:39:11Z</dc:date>
    <item>
      <title>Accumulation in script problem</title>
      <link>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615929#M227121</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 can't understand how to do accumulation total. I've some product operations like: income (BYE) and charge(SELL).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And Item detailed by fields [Item No_] and [Variant Code]. [Location Code] it's like Warehouse.&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;[Item No_]&lt;/SPAN&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;[Item No_]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to script:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_13983425637166563 jive_macro_code" jivemacro_uid="_13983425637166563"&gt;
&lt;P&gt;IF([Location Code]=Previous([Location Code]) and [Item No_] = Previous ([Item No_]) and [Variant Code]= Previous([Variant Code]),NumSum(Peek('QTY_Accum'),Num(Quantity)),Num(Quantity))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it's not working (&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Untitled.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/57866_Untitled.png" style="width: 620px; height: 196px;" /&gt;&lt;/P&gt;&lt;P&gt;My task to count a goods remaining balance accumulatively. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 12:46:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615929#M227121</guid>
      <dc:creator>lylererger</dc:creator>
      <dc:date>2014-04-24T12:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Accumulation in script problem</title>
      <link>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615930#M227122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In principle, your script looks OK. But I would still make the following changes:&lt;/P&gt;&lt;P&gt;1) Put the "Order By" in &lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;the same Load&lt;/EM&gt;&lt;/SPAN&gt; as where you define your QTY_Accum.&lt;/P&gt;&lt;P&gt;2) Define your QTY_Accum the following way:&lt;/P&gt;&lt;P&gt;Num(If( [Posting Date]&amp;nbsp; = Peek([Posting Date])&amp;nbsp; and &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Location Code] = Peek([Location Code]) and &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Item No_]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Peek([Item No_])&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Variant Code]&amp;nbsp; = Peek([Variant Code]),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; RangeSum(Peek('QTY_Accum'), Quantity),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Quantity )) as QTY_Accum&lt;/P&gt;&lt;P&gt;3) Add a debugging field to see the true record order withing the Load:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; RecNo() as RecordNumber&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 15:31:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615930#M227122</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2014-04-24T15:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Accumulation in script problem</title>
      <link>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615931#M227123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes HIC.&lt;BR /&gt;But we shouldn't consider the posting date.&lt;BR /&gt;Some peace of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13983650479916007" jivemacro_uid="_13983650479916007"&gt;
&lt;P&gt;[tmp]:&lt;/P&gt;
&lt;P&gt;LOAD * INLINE [&lt;/P&gt;
&lt;P&gt;&amp;nbsp; 'Posting Date','Location Code', 'Item No_', 'Variant Code', 'Entry Type',Quantity&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01.01.2013, 1, 1, 1, BYE, 10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02.01.2013, 1, 1, 1, BYE, 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02.01.2013, 1, 1, 1, SELL, -3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03.01.2013, 2, 1, 1, BYE, 20&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03.01.2013, 2, 1, 1, SELL, -10&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;tmp2:&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;/P&gt;
&lt;P&gt;LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; RecNo() as Rec,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Posting Date],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Location Code],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Item No_],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Variant Code],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [Entry Type],&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Quantity,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Num(If([Posting Date]&amp;nbsp; = Peek([Posting Date])&amp;nbsp; and [Location Code] = Peek([Location Code]) and&amp;nbsp; [Item No_] = Peek([Item No_]) and [Variant Code]&amp;nbsp; = Peek([Variant Code]), RangeSum(Peek('QTY_Accum'), Quantity), Quantity ))) as QTY_Accum,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Num(IF([Location Code] = Peek([Location Code]) and&amp;nbsp; [Item No_] = Peek([Item No_]) and [Variant Code]&amp;nbsp; = Peek([Variant Code]),NumSum(Peek('QTY_Accum2'),Num(Quantity)),Num(Quantity))) as QTY_Accum2&lt;/P&gt;
&lt;P&gt;Resident tmp&lt;/P&gt;
&lt;P&gt;Order by [Posting Date] asc,[Location Code] asc,[Item No_] asc,[Variant Code] asc;&lt;/P&gt;
&lt;P&gt;Drop Table tmp;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like we shouldn't consider date in condition of accumulation.&lt;/P&gt;&lt;P&gt;Any way thnx a lot.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;eek('QTY_A&lt;/SPAN&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;eek('QTY_A&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Apr 2014 18:39:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615931#M227123</guid>
      <dc:creator>lylererger</dc:creator>
      <dc:date>2014-04-24T18:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Accumulation in script problem</title>
      <link>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615932#M227124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this (to be modified for your situation)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14653206752572851 jive_text_macro" jivemacro_uid="_14653206752572851"&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// assumption: data is on level of %CATEG1_KEY, %CATEG2_KEY, Year, Month&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; *,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; If(Year = Peek('Year', -1) AND // if year of current record = year of pevious record and&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %CATEG1_KEY = Peek('%CATEG1_KEY', -1) AND // if same %CATEG1_KEY as previous record and&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %CATEG2_KEY = Peek('%CATEG2_KEY', -1), // if same %CATEG2_KEY as previous record&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; RangeSum(Peek('Sales_Acc', -1), Sales), // previous month + current month&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; RangeSum(Sales)) // use only first month of new year&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; AS Sales_Acc&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Resident Sales&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ORDER BY %CATEG1_KEY, %CATEG2_KEY, Year, Month; // order records by all categories (%CATEG1_KEY, %CATEG1_KEY), Year and Month to use peek function for accumulation&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt;If this helps you please mark it as helpful or correct.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px; font-family: arial, helvetica, sans-serif;"&gt;Thomas&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jun 2016 17:31:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Accumulation-in-script-problem/m-p/615932#M227124</guid>
      <dc:creator>thkarner</dc:creator>
      <dc:date>2016-06-07T17:31:41Z</dc:date>
    </item>
  </channel>
</rss>

