<?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: sum vs expression total in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451085#M168326</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help and for the explanation of the sum/if order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 May 2013 21:38:35 GMT</pubDate>
    <dc:creator>egoziyan</dc:creator>
    <dc:date>2013-05-12T21:38:35Z</dc:date>
    <item>
      <title>sum vs expression total</title>
      <link>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451082#M168323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I have a table with the following data&lt;/DIV&gt;&lt;DIV&gt;to_collect, &lt;SPAN style="color: #800000; font-size: 8pt;"&gt;QTY_ACTUAL&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;10,8&lt;/DIV&gt;&lt;DIV&gt;50,40&lt;/DIV&gt;&lt;DIV&gt;30,0&lt;/DIV&gt;&lt;DIV&gt;20,0&lt;/DIV&gt;&lt;DIV&gt;5,5&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I use the following command&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;if&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;SUM&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;QTY_ACTUAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) = 0,0,&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;SUM&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;to_collect&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I want it to show sum of 65.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;my problem is that it gives me a sum of 115. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Yaniv&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 May 2013 14:39:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451082#M168323</guid>
      <dc:creator>egoziyan</dc:creator>
      <dc:date>2013-05-12T14:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: sum vs expression total</title>
      <link>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451083#M168324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the following expression instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=Sum({&amp;lt;QTY_ACTUAL={"&amp;gt;0"}&amp;gt;} to_collect)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 May 2013 15:21:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451083#M168324</guid>
      <dc:creator>nagaiank</dc:creator>
      <dc:date>2013-05-12T15:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: sum vs expression total</title>
      <link>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451084#M168325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or you could do &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;QTY_ACTUAL = 0, 0, To_Collect)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i would think the set analysis expression Krishnamoorthy posted is faster&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For future reference, all you needed was to change the order of if and sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Think of it this way, what do you want to do first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case you want to check line by line to find 0 QTY and since sum is aggregate, you have to do the line by line inside the sum.&lt;/P&gt;&lt;P&gt;So it becomes SUM(IF(Something))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do this IF(SUM(Something)) then you first sum it and then check if its 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best wishes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 May 2013 15:45:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451084#M168325</guid>
      <dc:creator>calvindk</dc:creator>
      <dc:date>2013-05-12T15:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: sum vs expression total</title>
      <link>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451085#M168326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help and for the explanation of the sum/if order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 May 2013 21:38:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451085#M168326</guid>
      <dc:creator>egoziyan</dc:creator>
      <dc:date>2013-05-12T21:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: sum vs expression total</title>
      <link>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451086#M168327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;I have applied your answer and it works fine.&lt;/P&gt;&lt;P&gt;I tried to add to it a condition that calculate only the qty with family = 10 but for some reason I am getting the wrong result again.&lt;/P&gt;&lt;P&gt;the formula i'm using is &lt;/P&gt;&lt;P&gt;if&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;FAMILY&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={'10'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;QTY_ACTUAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) = 0,0,&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;FAMILY&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={'10'&lt;SPAN style="font-size: 10pt;"&gt;}&amp;gt;}To_Collect&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;when I am changing the TOTAL MODE from "expression total" to SUM of Rows it gives me the correct result but when I'm tring to add a column that gives the % that was actualy collected only for that was collected it sum the all To_Collect.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I want to get &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;(8+40+5) / (10+50+5) which is 81.53%&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;but insted I get&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;(8+40+5) / (10+50+30+20+5) which is 46.08%&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 May 2013 21:53:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-vs-expression-total/m-p/451086#M168327</guid>
      <dc:creator>egoziyan</dc:creator>
      <dc:date>2013-05-12T21:53:06Z</dc:date>
    </item>
  </channel>
</rss>

