<?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 Exclude negative values in Total aggregate value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291224#M1203016</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Pivot Table where I am displaying how the Commodities perform over a date range, see Table below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is calculating the Total Leakage value, which should exclude all negative values in the row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;The calculations&lt;/P&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;P&gt;1. Leakage calculation in its simplest form = (Lower GM%) - (Calculated GM%) * Sales&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Where Lower GM% is selected by users from a table and has a value 0 for this example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Calculated GM% = (Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT)&lt;/P&gt;&lt;P&gt;and is shown in the table below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. I display only the positive leakage values in the table and force the negative values to 0. I use this formula in QV to achieve this:&lt;/P&gt;&lt;P&gt;=&lt;B&gt;Rangemax&lt;/B&gt;(0, ((&lt;B&gt;Lower&lt;/B&gt; - ((&lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;SALES_AMOUNT&lt;/B&gt;) - &lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;COST_AMOUNT&lt;/B&gt;))/&lt;B&gt;sum&lt;/B&gt;(&lt;B&gt;SALES_AMOUNT&lt;/B&gt;))*100) * &lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;SALES_AMOUNT&lt;/B&gt;))/100 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;My Problem&lt;/P&gt;&lt;P&gt;5. My problem is when I am calculating the TOTAL LEAKAGE. I cannot exclude those negative values from my total leakage value. I have tried it using the following formula:&lt;/P&gt;&lt;P&gt;=Num((Aggr&lt;/P&gt;&lt;P&gt;(if(&lt;/P&gt;&lt;P&gt;(((Lower - ((Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT))*100) * Sum(SALES_AMOUNT))/100) &amp;gt;= 0,&lt;/P&gt;&lt;P&gt;((Lower - ((Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT))*100) * Sum(SALES_AMOUNT))/100,&lt;/P&gt;&lt;P&gt;0),&lt;/P&gt;&lt;P&gt;ESIS_Commodity))/1000,&lt;/P&gt;&lt;P&gt;'#####0','.',',')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE align="left" border="0" cellpadding="0" cellspacing="0" width="517"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P&gt;Total Leakage '000&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;Commodity&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;Date&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;2010-10&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;2010-09&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;5790 NEOPLAST TAPES AND DRESSINGS&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;Sales&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="20429.38"&gt;&lt;P style="text-align: right"&gt;20,429&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="1036.8"&gt;&lt;P style="text-align: right"&gt;1,037&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;5790 NEOPLAST TAPES AND DRESSINGS&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;GM%&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="0.31212449912821622"&gt;&lt;P style="text-align: right"&gt;31.21%&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="-910.18437499999993"&gt;&lt;P style="text-align: right"&gt;-91,018.44%&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P style="text-align: right"&gt;937&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;5790 NEOPLAST TAPES AND DRESSINGS&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;Leakage&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P style="text-align: right"&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P style="text-align: right"&gt;943679.16&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;For example:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;In 2010/10, Leakage ~ -6375.89 (it's negative, so I display 0)&lt;/P&gt;&lt;P&gt;In 2010/9, Leakage ~ 943679&lt;/P&gt;&lt;P style="font-weight: bold"&gt;So Total Leakage should only count +ve values and display ~ 943,000&lt;/P&gt;&lt;P&gt;Instead it displays as ~937,000 = (943679-6375.89)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you have any suggestions on how I can exclude the negatives and what I am doing wrong? The business to getting impatient to release this tool now and I do not even know if it possible to even do this in QV9?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;&lt;P&gt;Sahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Nov 2010 12:03:17 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-11-29T12:03:17Z</dc:date>
    <item>
      <title>Exclude negative values in Total aggregate value</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291224#M1203016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Pivot Table where I am displaying how the Commodities perform over a date range, see Table below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is calculating the Total Leakage value, which should exclude all negative values in the row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;The calculations&lt;/P&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;P&gt;1. Leakage calculation in its simplest form = (Lower GM%) - (Calculated GM%) * Sales&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Where Lower GM% is selected by users from a table and has a value 0 for this example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Calculated GM% = (Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT)&lt;/P&gt;&lt;P&gt;and is shown in the table below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. I display only the positive leakage values in the table and force the negative values to 0. I use this formula in QV to achieve this:&lt;/P&gt;&lt;P&gt;=&lt;B&gt;Rangemax&lt;/B&gt;(0, ((&lt;B&gt;Lower&lt;/B&gt; - ((&lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;SALES_AMOUNT&lt;/B&gt;) - &lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;COST_AMOUNT&lt;/B&gt;))/&lt;B&gt;sum&lt;/B&gt;(&lt;B&gt;SALES_AMOUNT&lt;/B&gt;))*100) * &lt;B&gt;Sum&lt;/B&gt;(&lt;B&gt;SALES_AMOUNT&lt;/B&gt;))/100 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;My Problem&lt;/P&gt;&lt;P&gt;5. My problem is when I am calculating the TOTAL LEAKAGE. I cannot exclude those negative values from my total leakage value. I have tried it using the following formula:&lt;/P&gt;&lt;P&gt;=Num((Aggr&lt;/P&gt;&lt;P&gt;(if(&lt;/P&gt;&lt;P&gt;(((Lower - ((Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT))*100) * Sum(SALES_AMOUNT))/100) &amp;gt;= 0,&lt;/P&gt;&lt;P&gt;((Lower - ((Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT))*100) * Sum(SALES_AMOUNT))/100,&lt;/P&gt;&lt;P&gt;0),&lt;/P&gt;&lt;P&gt;ESIS_Commodity))/1000,&lt;/P&gt;&lt;P&gt;'#####0','.',',')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE align="left" border="0" cellpadding="0" cellspacing="0" width="517"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P&gt;Total Leakage '000&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;Commodity&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;Date&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;2010-10&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;2010-09&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;5790 NEOPLAST TAPES AND DRESSINGS&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;Sales&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="20429.38"&gt;&lt;P style="text-align: right"&gt;20,429&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="1036.8"&gt;&lt;P style="text-align: right"&gt;1,037&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;5790 NEOPLAST TAPES AND DRESSINGS&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;GM%&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="0.31212449912821622"&gt;&lt;P style="text-align: right"&gt;31.21%&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93" num="-910.18437499999993"&gt;&lt;P style="text-align: right"&gt;-91,018.44%&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD valign="bottom" width="77"&gt;&lt;P style="text-align: right"&gt;937&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="161"&gt;&lt;P&gt;5790 NEOPLAST TAPES AND DRESSINGS&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P&gt;Leakage&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P style="text-align: right"&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;TD valign="bottom" width="93"&gt;&lt;P style="text-align: right"&gt;943679.16&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;For example:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;In 2010/10, Leakage ~ -6375.89 (it's negative, so I display 0)&lt;/P&gt;&lt;P&gt;In 2010/9, Leakage ~ 943679&lt;/P&gt;&lt;P style="font-weight: bold"&gt;So Total Leakage should only count +ve values and display ~ 943,000&lt;/P&gt;&lt;P&gt;Instead it displays as ~937,000 = (943679-6375.89)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you have any suggestions on how I can exclude the negatives and what I am doing wrong? The business to getting impatient to release this tool now and I do not even know if it possible to even do this in QV9?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;&lt;P&gt;Sahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Nov 2010 12:03:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291224#M1203016</guid>
      <dc:creator />
      <dc:date>2010-11-29T12:03:17Z</dc:date>
    </item>
    <item>
      <title>Exclude negative values in Total aggregate value</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291225#M1203017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sahar,&lt;/P&gt;&lt;P&gt;one idea is to use an addional field as flag. This field contains a '1' for positve values and a '0' for the negativ values. You can easily achieve this in your load script with an if-Statement like&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;load .... if (Amount&amp;lt; 0, 0,1) As AmountFlag.&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;After reloading you are able to use the flag in sum() like this &lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;=Sum(AMOUNT * AmountFlag)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;and you will sum up automatically only the positive values of AMOUNT. &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;HtH&lt;/P&gt;&lt;P&gt;Roland&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Nov 2010 13:12:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291225#M1203017</guid>
      <dc:creator />
      <dc:date>2010-11-29T13:12:45Z</dc:date>
    </item>
    <item>
      <title>Exclude negative values in Total aggregate value</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291226#M1203018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Roland&lt;/P&gt;&lt;P&gt;Thanks for the quick reply. It did cross my mind to load the calculation in my SQL. However, 'Amount' is a dynamic value. It changes depending on what value, users have picked as their Lower value.&lt;/P&gt;&lt;P&gt;The formula behind it is:&lt;/P&gt;&lt;P&gt;Amount = (Lower {This value is picked by users from a table and have values 0 to 90} - CalculatedGM%) * SalesAmount&lt;/P&gt;&lt;P&gt;How will I manipulate the Amount value in my Load script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Nov 2010 13:48:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291226#M1203018</guid>
      <dc:creator />
      <dc:date>2010-11-29T13:48:24Z</dc:date>
    </item>
    <item>
      <title>Exclude negative values in Total aggregate value</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291227#M1203019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Sahar,&lt;/P&gt;&lt;P&gt;I did'nt read your post carefully. In a load script you can't guess any users choice. So Set Analysis has to do the work. Can you send a little sample application that makes it much easier to examine?&lt;/P&gt;&lt;P&gt;Regards, Roland&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Nov 2010 15:13:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291227#M1203019</guid>
      <dc:creator />
      <dc:date>2010-11-29T15:13:09Z</dc:date>
    </item>
    <item>
      <title>Exclude negative values in Total aggregate value</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291228#M1203020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Roland&lt;/P&gt;&lt;P&gt;Managed to get it to work finally with a few nested loops around the original formula:&lt;/P&gt;&lt;P&gt;Many thanks for your help thus far, Sahar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P dir="ltr"&gt;=Aggr( SUM(Num((Aggr&lt;/P&gt;&lt;P dir="ltr"&gt;( if(&lt;/P&gt;&lt;P dir="ltr"&gt;(((AVG(Lower) - ((Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT))*100) * Sum(SALES_AMOUNT))/100) &amp;gt;= 0,&lt;/P&gt;&lt;P dir="ltr"&gt;((AVG(Lower) - ((Sum(SALES_AMOUNT) - Sum(COST_AMOUNT))/sum(SALES_AMOUNT))*100) * Sum(SALES_AMOUNT))/100,&lt;/P&gt;&lt;P dir="ltr"&gt;0),&lt;/P&gt;&lt;P dir="ltr"&gt;ESIS_Commodity,Date)),&lt;/P&gt;&lt;P dir="ltr"&gt;'#####0','.',',')),ESIS_Commodity)&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 17:15:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-negative-values-in-Total-aggregate-value/m-p/291228#M1203020</guid>
      <dc:creator />
      <dc:date>2010-12-01T17:15:59Z</dc:date>
    </item>
  </channel>
</rss>

