<?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 result depends on results in upper row in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112339#M90855</link>
    <description>&lt;P&gt;Please check 3rd line, should be -1672 not -2508. I have -2503 because it calculates 3x836 white 2x836 is correct. It shoudl start sum up avg_cons from 2nd line as result of upper row is positive&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2023 14:03:46 GMT</pubDate>
    <dc:creator>jacekp</dc:creator>
    <dc:date>2023-09-01T14:03:46Z</dc:date>
    <item>
      <title>calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112312#M90850</link>
      <description>&lt;P&gt;Hi Qlik Masters,&lt;/P&gt;
&lt;P&gt;I am facing some calculation problem with calculation that it is easy to do in excel.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have month, stock, avg_cons. Result is requested result we would like to see at the end.&lt;/P&gt;
&lt;P&gt;We can use stock only till the month that exists. Example we can use stock from month 1 only in month 1.&amp;nbsp; Stock from month 11 can be used till 11 month include.&lt;/P&gt;
&lt;P&gt;How we calculate:&lt;/P&gt;
&lt;P&gt;for the first month (first row) it is simly: stock - avg_cons&lt;/P&gt;
&lt;P&gt;2nd line: we check if results from upper month is bigger than 0, if yes, then stock(current line) - avg_cons(current line), if not it is: result from the upper month + stock(current line) - avg_stock(current line)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 216pt;" border="0" width="288" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD width="72" height="19" style="height: 14.25pt; width: 54pt;"&gt;month&lt;/TD&gt;
&lt;TD width="72" style="width: 54pt;"&gt;stock&lt;/TD&gt;
&lt;TD width="72" style="width: 54pt;"&gt;avg_cons&lt;/TD&gt;
&lt;TD width="72" style="width: 54pt;"&gt;result&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;9227&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;8390.75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;2&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-836.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-1672.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;4&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-2508.75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;5&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-3345&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;6&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-4181.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;7&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-5017.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;8&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-5853.75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;9&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-6690&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;10&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-7526.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;11&lt;/TD&gt;
&lt;TD align="right"&gt;10890&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;2527.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;12&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;-836.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.25pt;"&gt;13&lt;/TD&gt;
&lt;TD align="right"&gt;5045&lt;/TD&gt;
&lt;TD align="right"&gt;836.25&lt;/TD&gt;
&lt;TD align="right" class="xl63"&gt;3372.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem I have is to somehow define in formula range of avg_cons that needs to be taken for calculation.&lt;/P&gt;
&lt;P&gt;Any idea how to deal with it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if(&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;above(&lt;BR /&gt;sum(aggr(Sum(&lt;BR /&gt;{&amp;lt;Dataview = {"Stock"}&lt;BR /&gt;&amp;gt;}&lt;BR /&gt;Value),YearMonth))&lt;BR /&gt;-&lt;BR /&gt;rangesum(above(Sum({&amp;lt;Dataview = {"consumption"}&amp;gt;}Value),0,rowno()))&lt;BR /&gt;)&lt;BR /&gt;&amp;gt;0,&lt;/P&gt;
&lt;P&gt;sum(aggr(Sum(&lt;BR /&gt;{&amp;lt;Dataview = {"Stock"}&lt;BR /&gt;&amp;gt;}&lt;BR /&gt;Value),YearMonth))&lt;BR /&gt;-&lt;BR /&gt;rangesum(above(Sum({&amp;lt;Dataview = {"consumption"}&amp;gt;}Value),rowno()-1,rowno()))&lt;BR /&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sum(aggr(Sum(&lt;BR /&gt;{&amp;lt;Dataview = {"Stock"}&lt;BR /&gt;&amp;gt;}&lt;BR /&gt;Value),YearMonth))&lt;BR /&gt;-&lt;BR /&gt;rangesum(above(Sum({&amp;lt;Dataview = {"consumption"}&amp;gt;}Value),0,rowno()))&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 12:57:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112312#M90850</guid>
      <dc:creator>jacekp</dc:creator>
      <dc:date>2023-09-01T12:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112315#M90851</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;
&lt;P&gt;I think you are almost there, but I'd recommend to include all of the logic inside the AGGR() function, not outside of it. So, the overall formula should look like this:&lt;/P&gt;
&lt;P&gt;sum(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;AGGR(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IF( Above( ...) &amp;gt;0, ...., .....)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; YearMonth&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;I'm teaching advanced uses of Set Analysis and AGGR() at the&amp;nbsp;&lt;A href="https://masterssummit.com" target="_blank"&gt;Masters Summit for Qlik&lt;/A&gt;&amp;nbsp; and my colleagues Rob Wunderlich, Barry Harmsen, Bill Lay and Nick Webster teach many other advanced development techniques. Check out our agenda - we are coming soon to Orlando and to Dublin!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 13:14:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112315#M90851</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2023-09-01T13:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112319#M90852</link>
      <description>&lt;P&gt;if I include formula inside the aggr funtion nothing has changed&lt;/P&gt;
&lt;P&gt;it returns, as initial&lt;/P&gt;
&lt;TABLE width="297"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;1&lt;/TD&gt;
&lt;TD width="204"&gt;8390.75&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;2&lt;/TD&gt;
&lt;TD width="204"&gt;-836.25&amp;nbsp;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;3&lt;/TD&gt;
&lt;TD width="204"&gt;-2508.75&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;4&lt;/TD&gt;
&lt;TD width="204"&gt;-3345&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;5&lt;/TD&gt;
&lt;TD width="204"&gt;-4181.25&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;6&lt;/TD&gt;
&lt;TD width="204"&gt;-5017.5&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;7&lt;/TD&gt;
&lt;TD width="204"&gt;-5853.75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;8&lt;/TD&gt;
&lt;TD width="204"&gt;-6690&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;9&lt;/TD&gt;
&lt;TD width="204"&gt;-7526.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;10&lt;/TD&gt;
&lt;TD width="204"&gt;-8362.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;11&lt;/TD&gt;
&lt;TD width="204"&gt;1691.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;12&lt;/TD&gt;
&lt;TD width="204"&gt;-836.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="93"&gt;13&lt;/TD&gt;
&lt;TD width="204"&gt;-5826.25&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 01 Sep 2023 13:26:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112319#M90852</guid>
      <dc:creator>jacekp</dc:creator>
      <dc:date>2023-09-01T13:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112322#M90853</link>
      <description>&lt;P&gt;I don't quite understand what's the problem and what are you trying to achieve. Based on your description of the logic, your formula works exactly as expected. What are you trying to do differently?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 13:31:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112322#M90853</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2023-09-01T13:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112339#M90855</link>
      <description>&lt;P&gt;Please check 3rd line, should be -1672 not -2508. I have -2503 because it calculates 3x836 white 2x836 is correct. It shoudl start sum up avg_cons from 2nd line as result of upper row is positive&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 14:03:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112339#M90855</guid>
      <dc:creator>jacekp</dc:creator>
      <dc:date>2023-09-01T14:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112378#M90862</link>
      <description>&lt;P&gt;I see... Maybe this is too much to be calculated in a chart expression - perhaps you move at least some of these calculations to the data load script?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I have a feeling that the approach is overly complicated. Can you formulate the business logic behind all these calculations? What are you trying to calculate, in business terms?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 15:16:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112378#M90862</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2023-09-01T15:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112431#M90864</link>
      <description>&lt;P&gt;Any suggestion how divide it for the script and formula?&lt;/P&gt;
&lt;P&gt;Let's say that stock and month presents exipry date and we can't use it next month. While the demand is 836per month. In first month then stock - demand shows scrapping. Starting from the second month you can only use stock with exipry date of 11.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 18:43:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112431#M90864</guid>
      <dc:creator>jacekp</dc:creator>
      <dc:date>2023-09-01T18:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: calculate result depends on results in upper row</title>
      <link>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112589#M90867</link>
      <description>&lt;P&gt;I'm describing a similar process in a lot of detail in my book &lt;A href="https://amzn.to/45yyxdU" target="_blank" rel="noopener"&gt;QlikView Your Business&lt;/A&gt;, in a chapter devoted to Inventory Analysis. I encourage you to check it out.&lt;/P&gt;
&lt;P&gt;In a few words, you will need to use functions &lt;STRONG&gt;Peek() and Previous()&lt;/STRONG&gt;&amp;nbsp;to calculate cumulative balances. You will need to load your data sorted chronologically. For each inventory balance, you'd check the expiration date and calculate useful stock and waste.&lt;/P&gt;
&lt;P&gt;You can find several blog articles about Peek() and Previous(), including &lt;A href="https://www.naturalsynergies.com/q-tip-12-peek-or-previous/" target="_blank" rel="noopener"&gt;my own&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2023 16:42:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/calculate-result-depends-on-results-in-upper-row/m-p/2112589#M90867</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2023-09-02T16:42:08Z</dc:date>
    </item>
  </channel>
</rss>

