<?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: Code to calculate consecutive negative or positive monthly values in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1918381#M75520</link>
    <description>&lt;P&gt;There is an example for exactly this on&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/Counters-in-the-Load/ba-p/1464117" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/Counters-in-the-Load/ba-p/1464117&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 07:19:36 GMT</pubDate>
    <dc:creator>hic</dc:creator>
    <dc:date>2022-04-14T07:19:36Z</dc:date>
    <item>
      <title>Code to calculate consecutive negative or positive monthly values</title>
      <link>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1918368#M75519</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wondering if anyone has a "simple" way to create the score indicator below.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Each month has a score assigned to it.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;The ask is to then provide a score indicator as to how many months the score has been going up or down &lt;STRONG&gt;consecutively&lt;/STRONG&gt;.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 528pt;" border="0" width="704" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl64" style="height: 15.0pt; width: 48pt;"&gt;jan&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;feb&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;mar&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;apr&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;may&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;jun&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;jul&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;aug&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;sep&lt;/TD&gt;
&lt;TD width="64" class="xl64" style="border-left: none; width: 48pt;"&gt;oct&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Score&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;31&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;38&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;38&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;56&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;99&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;100&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;98&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;96&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;94&lt;/TD&gt;
&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;-3&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Above.... the Score of -3 indicates that for the past 3 months the score has been going down.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i.e. from July onwards the trend has been consecutively down. (100 &amp;gt; 98 &amp;gt; 96 &amp;gt; 94)&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If the Scores had been&amp;nbsp;&lt;STRONG&gt;consecutively&amp;nbsp;&lt;/STRONG&gt; going down since April the Score would be -6&lt;/LI&gt;
&lt;LI&gt;If the scores had been going&amp;nbsp;&lt;STRONG style="font-family: inherit;"&gt;up&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;since August, the score would be &lt;/SPAN&gt;&lt;STRONG style="font-family: inherit;"&gt;+2&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;In the code is there a way anyone can think of doing this?&amp;nbsp; I was thinking of using the previous function somehow but it starts to get messy quite soon so any thoughts are appreciated.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 06:51:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1918368#M75519</guid>
      <dc:creator>cb5981</dc:creator>
      <dc:date>2022-04-14T06:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Code to calculate consecutive negative or positive monthly values</title>
      <link>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1918381#M75520</link>
      <description>&lt;P&gt;There is an example for exactly this on&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/Counters-in-the-Load/ba-p/1464117" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/Counters-in-the-Load/ba-p/1464117&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 07:19:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1918381#M75520</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2022-04-14T07:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Code to calculate consecutive negative or positive monthly values</title>
      <link>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1921046#M75825</link>
      <description>&lt;P&gt;Thanks Henric,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've had a play around with the code here but still not 100% sure on how to implement counters if negative as well (it seems to only account for positive scores).&amp;nbsp; i.e. if months jan - mar were increasing, it would be +2, but then from Mar - Jun if they were decreasing I should see -3.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 16:14:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1921046#M75825</guid>
      <dc:creator>cb5981</dc:creator>
      <dc:date>2022-04-21T16:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Code to calculate consecutive negative or positive monthly values</title>
      <link>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1922088#M75897</link>
      <description>&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;Load&lt;BR /&gt;If(Trend=Peek(Trend),Peek(Score)+Trend,Trend) as Score,&lt;BR /&gt;*;&lt;BR /&gt;Load&lt;BR /&gt;If(Change=0,Peek(Trend),Sign(Change)) as Trend,&lt;BR /&gt;*;&lt;BR /&gt;Load&lt;BR /&gt;ID,&lt;BR /&gt;Month,&lt;BR /&gt;Value,&lt;BR /&gt;Value - Peek(Value) as Change&lt;BR /&gt;Resident SourceData&lt;BR /&gt;Order By Month;&lt;/P&gt;&lt;P&gt;Let Score = Peek('Score',-1,'Data');&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Henric_Cronstrm_0-1650887205327.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/77800iBB7B8F46E5339757/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Henric_Cronstrm_0-1650887205327.png" alt="Henric_Cronstrm_0-1650887205327.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 11:46:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Code-to-calculate-consecutive-negative-or-positive-monthly/m-p/1922088#M75897</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2022-04-25T11:46:59Z</dc:date>
    </item>
  </channel>
</rss>

