<?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 How to calculate accumulated amount in script? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-calculate-accumulated-amount-in-script/m-p/180467#M46888</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kristofer,&lt;/P&gt;&lt;P&gt;Using peek() and previous() functions will help you to do that. My untested guess for your new field is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;If(Unit = Previous(Unit), Rangesum(Amount_Month, Peek(Amount_Month))) AS Amount_YTD,&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Of course you can add new conditionals to compare with previous periods or previous fields.&lt;/P&gt;&lt;P&gt;Anyway, the more complex your field is, the longer the load will take.&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Aug 2010 18:54:33 GMT</pubDate>
    <dc:creator>Miguel_Angel_Baeyens</dc:creator>
    <dc:date>2010-08-30T18:54:33Z</dc:date>
    <item>
      <title>How to calculate accumulated amount in script?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-accumulated-amount-in-script/m-p/180466#M46887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;YTD-questions seems to be a common question but I can't find a previous solution for my YTD-problem.&lt;/P&gt;&lt;P&gt;I got a table that inclueds Unit, Period and Amount_Month. I like to calculate a new field in the script with Amount_YTD as shown in the table below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 194pt; border-collapse: collapse;" width="259"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 32pt; mso-width-source: userset; mso-width-alt: 1572;" width="43" /&gt;&lt;COL style="width: 37pt; mso-width-source: userset; mso-width-alt: 1792;" width="49" /&gt;&lt;COL style="width: 77pt; mso-width-source: userset; mso-width-alt: 3766;" width="103" /&gt;&lt;COL style="width: 48pt;" width="64" /&gt;&lt;/COLGROUP&gt;&lt;TBODY&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD class="xl22" height="17" style="background-color: transparent; width: 32pt; height: 12.75pt; border: #ece9d8;" width="43"&gt;&lt;STRONG&gt;Unit&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl22" style="background-color: transparent; width: 37pt; border: #ece9d8;" width="49"&gt;&lt;STRONG&gt;Period&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl22" style="background-color: transparent; width: 77pt; border: #ece9d8;" width="103"&gt;&lt;STRONG&gt;Amount_Month&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl22" style="background-color: transparent; width: 48pt; border: #ece9d8;" width="64"&gt;&lt;STRONG&gt;Amount_YTD&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;C&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;200910&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;25&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C2"&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;C&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;200911&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;50&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D2+C3"&gt;75&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;C&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;200912&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-600&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D3+C4"&gt;-525&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201001&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;400&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C5"&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201002&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-200&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D5+C6"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201003&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;0&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D6+C7"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201004&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;300&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D7+C8"&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201005&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-500&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D8+C9"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201006&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-100&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D9+C10"&gt;-100&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201007&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;200&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D10+C11"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201008&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;300&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D11+C12"&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201009&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;0&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D12+C13"&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201010&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;100&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D13+C14"&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201011&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;250&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D14+C15"&gt;750&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;A&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201012&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-150&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=D15+C16"&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201001&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;200&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C17"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201002&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;300&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C18+D17"&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201003&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;0&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C19+D18"&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201004&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;100&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C20+D19"&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201005&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;250&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C21+D20"&gt;850&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201006&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-150&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C22+D21"&gt;700&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201007&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;400&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C23+D22"&gt;1100&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201008&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-200&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C24+D23"&gt;900&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201009&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;0&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C25+D24"&gt;900&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201010&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;200&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C26+D25"&gt;1100&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201011&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;300&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C27+D26"&gt;1400&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;B&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;201012&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;"&gt;-150&lt;/TD&gt;&lt;TD align="right" style="background-color: transparent; border: #ece9d8;" fmla="=C28+D27"&gt;1250&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 17:41:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-accumulated-amount-in-script/m-p/180466#M46887</guid>
      <dc:creator />
      <dc:date>2010-08-30T17:41:15Z</dc:date>
    </item>
    <item>
      <title>How to calculate accumulated amount in script?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-accumulated-amount-in-script/m-p/180467#M46888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kristofer,&lt;/P&gt;&lt;P&gt;Using peek() and previous() functions will help you to do that. My untested guess for your new field is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;If(Unit = Previous(Unit), Rangesum(Amount_Month, Peek(Amount_Month))) AS Amount_YTD,&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Of course you can add new conditionals to compare with previous periods or previous fields.&lt;/P&gt;&lt;P&gt;Anyway, the more complex your field is, the longer the load will take.&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 18:54:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-accumulated-amount-in-script/m-p/180467#M46888</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2010-08-30T18:54:33Z</dc:date>
    </item>
    <item>
      <title>How to calculate accumulated amount in script?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-accumulated-amount-in-script/m-p/180468#M46889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanx for your answer. Your tip got me on the right track. I had to adjust the last peek to Amount_YTD. This soleved my problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If&lt;BR /&gt;&lt;BR /&gt;(Unit = Previous(Unit) &lt;B&gt;and&lt;/B&gt; left(Period,4) = previous(left(Period,4)), rangesum(Amount_Month, Peek('Amount_YTD')),Amount_Month) &lt;B&gt;as&lt;/B&gt; Amount_YTD&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 19:30:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-accumulated-amount-in-script/m-p/180468#M46889</guid>
      <dc:creator />
      <dc:date>2010-08-30T19:30:02Z</dc:date>
    </item>
  </channel>
</rss>

