<?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: Assistance with sum function in script: in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693742#M1074404</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *,&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvTotal - rangesum(Duty, MPF, HMF, DocTurnOver) as newfield&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from online help&lt;/P&gt;&lt;P class="syntax"&gt;&lt;A name="kanchor972"&gt;&lt;/A&gt;&lt;A name="rangesum"&gt;&lt;/A&gt;&lt;SPAN class="Bold"&gt;&lt;EM&gt;rangesum(&lt;/EM&gt;&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN class="Italic"&gt;expr1 [ , expr2, ... exprN ]&lt;/SPAN&gt;&lt;SPAN class="Bold"&gt;)&lt;/SPAN&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Returns the sum of a range of 1 to N arguments. As opposed to the &lt;SPAN style="font-size: 11pt; font-weight: bold;"&gt;+&lt;/SPAN&gt; operator, &lt;SPAN class="Bold"&gt;rangesum&lt;/SPAN&gt; will treat all non-numeric values as 0. &lt;/EM&gt;&lt;/P&gt;&lt;P class="example"&gt;&lt;EM&gt;Examples:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="Code"&gt;rangesum (1,2,4)&lt;/SPAN&gt; returns 7&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="Code"&gt;rangesum (1,'xyz')&lt;/SPAN&gt; returns 1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="Code"&gt;rangesum (null( ))&lt;/SPAN&gt; returns 0&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Jul 2014 19:59:43 GMT</pubDate>
    <dc:creator>maxgro</dc:creator>
    <dc:date>2014-07-31T19:59:43Z</dc:date>
    <item>
      <title>Assistance with sum function in script:</title>
      <link>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693740#M1074402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load number&lt;/P&gt;&lt;P&gt;InvTotal&lt;/P&gt;&lt;P&gt;Duty&lt;/P&gt;&lt;P&gt;MPF&lt;/P&gt;&lt;P&gt;HMF&lt;/P&gt;&lt;P&gt;DocTurnOver&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to write a new column in my table that is &lt;/P&gt;&lt;P&gt;InvTotal minus the following: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Duty&lt;/P&gt;&lt;P&gt;MPF&lt;/P&gt;&lt;P&gt;HMF&lt;/P&gt;&lt;P&gt;DocTurnOver&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried it several different ways with out anything working.&lt;/P&gt;&lt;P&gt;Not sure if it matters, but &lt;/P&gt;&lt;P&gt;InvTotal has value for ALL Load numbers&lt;/P&gt;&lt;P&gt;Rest of the fields may be blank.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 17:06:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693740#M1074402</guid>
      <dc:creator />
      <dc:date>2014-07-31T17:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance with sum function in script:</title>
      <link>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693741#M1074403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;InvTotal,&lt;/P&gt;&lt;P&gt;Duty,&lt;/P&gt;&lt;P&gt;MPF,&lt;/P&gt;&lt;P&gt;HMF,&lt;/P&gt;&lt;P&gt;DocTurnOver,&lt;/P&gt;&lt;P&gt;InvTotal - (Duty&amp;nbsp; + MPF + HMF + DocTurnOver) as Calculation&lt;/P&gt;&lt;P&gt;from ....;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one thing to consider is if you have null values in one of the fields, the calculation will be null as null propagates in Qlikview. so if that is the case, then you will have to either set the values to zero or skip the null values...something like below: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;option 1:&lt;/P&gt;&lt;P&gt;load *,&lt;/P&gt;&lt;P&gt;InvTotal - (Duty&amp;nbsp; + MPF + HMF + DocTurnOver) as Calculation;&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;alt(InvTotal, 0) as InvTotal,&lt;/P&gt;&lt;P&gt;alt(Duty, 0) as Duty,&lt;/P&gt;&lt;P&gt;alt(MPF, 0) as MPF,&lt;/P&gt;&lt;P&gt;alt(HMF, 0) as HMF,&lt;/P&gt;&lt;P&gt;alt(DocTurnOver, 0) as DocTurnOver&lt;/P&gt;&lt;P&gt;from ....;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;option 2:&lt;/P&gt;&lt;P&gt;load *,&lt;/P&gt;&lt;P&gt;If(isnull(InvTotal) or isnull(Duty) or isnull(MPF) or isnull(HMF) or isnull(DocTurnOver), 0, InvTotal - (Duty&amp;nbsp; + MPF + HMF + DocTurnOver)) as Calculation&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt;InvTotal,&lt;/P&gt;&lt;P&gt;Duty,&lt;/P&gt;&lt;P&gt;MPF,&lt;/P&gt;&lt;P&gt;HMF,&lt;/P&gt;&lt;P&gt;DocTurnOver&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from ....;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 17:27:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693741#M1074403</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-31T17:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance with sum function in script:</title>
      <link>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693742#M1074404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *,&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvTotal - rangesum(Duty, MPF, HMF, DocTurnOver) as newfield&lt;/P&gt;&lt;P style="font-size: 12.727272033691406px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from online help&lt;/P&gt;&lt;P class="syntax"&gt;&lt;A name="kanchor972"&gt;&lt;/A&gt;&lt;A name="rangesum"&gt;&lt;/A&gt;&lt;SPAN class="Bold"&gt;&lt;EM&gt;rangesum(&lt;/EM&gt;&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN class="Italic"&gt;expr1 [ , expr2, ... exprN ]&lt;/SPAN&gt;&lt;SPAN class="Bold"&gt;)&lt;/SPAN&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Returns the sum of a range of 1 to N arguments. As opposed to the &lt;SPAN style="font-size: 11pt; font-weight: bold;"&gt;+&lt;/SPAN&gt; operator, &lt;SPAN class="Bold"&gt;rangesum&lt;/SPAN&gt; will treat all non-numeric values as 0. &lt;/EM&gt;&lt;/P&gt;&lt;P class="example"&gt;&lt;EM&gt;Examples:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="Code"&gt;rangesum (1,2,4)&lt;/SPAN&gt; returns 7&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="Code"&gt;rangesum (1,'xyz')&lt;/SPAN&gt; returns 1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="Code"&gt;rangesum (null( ))&lt;/SPAN&gt; returns 0&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 19:59:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693742#M1074404</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-07-31T19:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance with sum function in script:</title>
      <link>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693743#M1074405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simple and elegant solution Massimo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still need to check if InvTotal is null or not, right? Why not include it within rangesum and assign negative values to other fields?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 23:24:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693743#M1074405</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-31T23:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Assistance with sum function in script:</title>
      <link>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693744#M1074406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can use alt, len(trim(...))&amp;gt;0, isnull() &lt;/P&gt;&lt;P&gt;or may be (try, I think it should work)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px;"&gt;rangesum(InvTotal, -Duty, -MPF, -HMF, -DocTurnOver) as newfield&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Aug 2014 07:20:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Assistance-with-sum-function-in-script/m-p/693744#M1074406</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-08-01T07:20:25Z</dc:date>
    </item>
  </channel>
</rss>

