<?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: Nested IF while, ignore negative values with exception in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337638#M493200</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Roberto for your quick reply; I have tried your expression and it works to some degree.&lt;/P&gt;&lt;P&gt;What I mean by that is the numbers in the Combined column are OK, but when I do a Total for the ID dimenssion, the result is &lt;STRONG&gt;0&lt;/STRONG&gt;, when it should be &lt;STRONG&gt;80&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="15505" alt="QV_negValuesIssue.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/15505_QV_negValuesIssue.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either I'm missing something, or this is kinda strange behaviour from QV.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Jun 2012 19:33:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-06-05T19:33:14Z</dc:date>
    <item>
      <title>Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337636#M493198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a special case/user requirement that in a pivot table I would show a SUM, ignore negative values from the source table BUT make one exception.&lt;/P&gt;&lt;P&gt;I believe a nested IF should do the trick, but all my tries so far failed; I got a bunch of different results... except of course, the one I'm looking for :-).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like my syntax is correct, but my logic is wrong; I was wondering if the Community may be able to point me in the right direction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SOURCE TABLE 1&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 20%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Value1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SOURCE TABLE 2&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 20%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Value 2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;-10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;-20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Pivot Table is simple:&lt;/P&gt;&lt;P&gt;Dimmension: ID&lt;/P&gt;&lt;P&gt;Expression: Sum(Value1 * Value2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The desired Pivot Table would look like this:&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 20%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Header 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Header 2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;-20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically:&lt;/P&gt;&lt;P&gt;1. IF(Sum(Value1*Value2)&amp;lt;=0,0,Sum(Value1*Value2))&lt;/P&gt;&lt;P&gt;2. IF(Table2.ID = '3', Sum(Value1*Value2))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I combine the two IFs so that it will ignore (0) &lt;STRONG&gt;all&lt;/STRONG&gt; negative values in SOURCE TABLE 2 except where ID=3?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 12:27:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337636#M493198</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-06-05T12:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337637#M493199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that this expression will help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;IF(ID = 3, Sum(Value1*[Value 2] ),&lt;/P&gt;&lt;P&gt; IF(Sum(Value1*[Value 2])&amp;lt;=0,0,Sum(Value1*[Value 2]))&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached file for the sample.qvw that I made for this issue&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 12:43:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337637#M493199</guid>
      <dc:creator />
      <dc:date>2012-06-05T12:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337638#M493200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Roberto for your quick reply; I have tried your expression and it works to some degree.&lt;/P&gt;&lt;P&gt;What I mean by that is the numbers in the Combined column are OK, but when I do a Total for the ID dimenssion, the result is &lt;STRONG&gt;0&lt;/STRONG&gt;, when it should be &lt;STRONG&gt;80&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="15505" alt="QV_negValuesIssue.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/15505_QV_negValuesIssue.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either I'm missing something, or this is kinda strange behaviour from QV.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 19:33:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337638#M493200</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-06-05T19:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337639#M493201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may want to try moving your sum aggregation outside of the IF statement.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMBINED Column&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(IF(ID = 3, Value1*[Value 2],&lt;/P&gt;&lt;P&gt;if(Value1*[Value 2]&amp;lt;=0&lt;/P&gt;&lt;P&gt;&amp;nbsp; ,0&lt;/P&gt;&lt;P&gt;&amp;nbsp; ,Value1*[Value 2]&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached Roberto's sample with the modified formulas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 23:22:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337639#M493201</guid>
      <dc:creator />
      <dc:date>2012-06-05T23:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337640#M493202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want that it ignores only the negative values in &lt;EM&gt;&lt;STRONG&gt;TABLE 2&lt;/STRONG&gt;&lt;/EM&gt;, except when ID=3, then .......&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;Sum(If(ID=3,Value2*Value1,If(&lt;STRONG&gt;&lt;EM&gt;Value2&lt;/EM&gt;&amp;lt;=0&lt;/STRONG&gt;,0,Value2*Value1)))&lt;BR /&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jun 2012 03:16:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337640#M493202</guid>
      <dc:creator>jemancilla</dc:creator>
      <dc:date>2012-06-06T03:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337641#M493203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, I didn't notice the incorrect total. Datawitch indeed seems to have the corrected version for you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jun 2012 05:26:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337641#M493203</guid>
      <dc:creator />
      <dc:date>2012-06-06T05:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337642#M493204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Absolutely great stuff; Datawitch expression does give me the result I want. I struggled with this for a few days and now I look at the solution and it seems so simple! Not a good feeling for me :-).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much everyone for the help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS Apologies to Datawitch as I can only have one correct answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jun 2012 12:12:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337642#M493204</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-06-06T12:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Nested IF while, ignore negative values with exception</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337643#M493205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No worries, I'm glad I was able to help.&amp;nbsp; I ran into that a few months ago myself.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jun 2012 16:11:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-while-ignore-negative-values-with-exception/m-p/337643#M493205</guid>
      <dc:creator />
      <dc:date>2012-06-06T16:11:50Z</dc:date>
    </item>
  </channel>
</rss>

