<?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 Sum of next N non null values in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Sum-of-next-N-non-null-values/m-p/1926506#M76289</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a table chart like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mattiasthalen_0-1651690916538.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/78695i8CDDDDCCF8955091/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mattiasthalen_0-1651690916538.png" alt="mattiasthalen_0-1651690916538.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'm trying to get the sum of the next 4 non null values (including current value). So I want to start by looking at the current row, and if it's not null gather it. Continue to next row and do the same. When 4 non null values have been collected, I want to sum them. And it needs to happen in the UI/Chart, not in the script.&lt;/P&gt;
&lt;P&gt;I've only been able to use Below, but then I need to set a larger window and risk summing more than the next 4 values. If I set it as RangeSum(Below(Column(1), 0 , 4)) then I risk summing fewer values than intended.&lt;/P&gt;
&lt;P&gt;I tried using FirstSortedValue and put the null values at the bottom of the sorting, but I think it works by looking at the internal table and not the chart.&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2022 19:16:51 GMT</pubDate>
    <dc:creator>mattias-thalen</dc:creator>
    <dc:date>2022-05-04T19:16:51Z</dc:date>
    <item>
      <title>Sum of next N non null values</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-next-N-non-null-values/m-p/1926506#M76289</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a table chart like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mattiasthalen_0-1651690916538.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/78695i8CDDDDCCF8955091/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mattiasthalen_0-1651690916538.png" alt="mattiasthalen_0-1651690916538.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'm trying to get the sum of the next 4 non null values (including current value). So I want to start by looking at the current row, and if it's not null gather it. Continue to next row and do the same. When 4 non null values have been collected, I want to sum them. And it needs to happen in the UI/Chart, not in the script.&lt;/P&gt;
&lt;P&gt;I've only been able to use Below, but then I need to set a larger window and risk summing more than the next 4 values. If I set it as RangeSum(Below(Column(1), 0 , 4)) then I risk summing fewer values than intended.&lt;/P&gt;
&lt;P&gt;I tried using FirstSortedValue and put the null values at the bottom of the sorting, but I think it works by looking at the internal table and not the chart.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 19:16:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-next-N-non-null-values/m-p/1926506#M76289</guid>
      <dc:creator>mattias-thalen</dc:creator>
      <dc:date>2022-05-04T19:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of next N non null values</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-next-N-non-null-values/m-p/1926565#M76297</link>
      <description>&lt;P&gt;If you exclude the nulls from your chart (in Date column use Limitation &amp;gt; Exact value &amp;gt;0)&lt;BR /&gt;and extend range to 4, you get your result ..&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lisa_P_0-1651717252444.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/78701iD0CD05C8B9DEA6B0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lisa_P_0-1651717252444.png" alt="Lisa_P_0-1651717252444.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 02:22:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-next-N-non-null-values/m-p/1926565#M76297</guid>
      <dc:creator>Lisa_P</dc:creator>
      <dc:date>2022-05-05T02:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of next N non null values</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-next-N-non-null-values/m-p/1926609#M76306</link>
      <description>&lt;P&gt;I'm sorry for being unclear. This is not an option, all rows must exist.&lt;/P&gt;
&lt;P&gt;The solution I have so far is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Let _var_PBC_MinSignalWindow    = 8;
Let _var_PBC_MaxSignalWindow    = $(_var_PBC_MinSignalWindow)*2;

For i = 0 to $(_var_PBC_MaxSignalWindow)

    Let _var_PBC_SignalWindow       = $(_var_PBC_MinSignalWindow) + $(i);
    Let _var_PBC_SignalBelow        = 'Below(Column(1), 0, $(_var_PBC_SignalWindow))';
    Let _var_PBC_SignalBelowCheck   = 'RangeNumericCount($(_var_PBC_SignalBelow)) = $(_var_PBC_MinSignalWindow)';
    Let _var_PBC_RangeMin_Formula   = 'If($(_var_PBC_SignalBelowCheck), RangeMin($(_var_PBC_SignalBelow)))';
    Let _var_PBC_RangeMax_Formula   = 'If($(_var_PBC_SignalBelowCheck), RangeMax($(_var_PBC_SignalBelow)))';

    Switch i
        Case 0
            Let _var_PBC_RangeMin   = '$(_var_PBC_RangeMin_Formula)';
            Let _var_PBC_RangeMax   = '$(_var_PBC_RangeMax_Formula)';
        
        Default
            Let _var_PBC_RangeMin   = '$(_var_PBC_RangeMin), $(_var_PBC_RangeMin_Formula)';
            Let _var_PBC_RangeMax   = '$(_var_PBC_RangeMax), $(_var_PBC_RangeMax_Formula)';

    End Switch

    Let _var_PBC_SignalWindow       = Null();
    Let _var_PBC_SignalBelow        = Null();
    Let _var_PBC_SignalBelowCheck   = Null();
    Let _var_PBC_RangeMin_Formula   = Null();
    Let _var_PBC_RangeMax_Formula   = Null();

Next i

Let i = Null();

Set _var_PBC_RangeMin = Alt($(_var_PBC_RangeMin));
Set _var_PBC_RangeMax = Alt($(_var_PBC_RangeMax));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So basically I do a RangeNumericCount for the range N, if that matches N, then proceed.&lt;/P&gt;
&lt;P&gt;Else, check N+1, N+2, N+3... N*2&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 06:59:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-next-N-non-null-values/m-p/1926609#M76306</guid>
      <dc:creator>mattias-thalen</dc:creator>
      <dc:date>2022-05-05T06:59:29Z</dc:date>
    </item>
  </channel>
</rss>

