<?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 and sum statement in the Expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960783#M956481</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This should work&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=Sum(If((ConType = ContractRef Or IsNull(ConType)) And (Match(SUPStatus, 1, 4, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; = 0 Or IsNull(SUPStatus)), [SUP#]))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Set analysis usually performs much better than a sum(if()) structure, but it is not so easy to include nulls (just as it is not possible to select nulls in the front end). So i suggest that you post a sample qvw file for more detailed analysis. Or you can set a flag at load time and use that in a set expression. Something like:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...If((ConType = ContractRef Or IsNull(ConType)) And (Match(SUPStatus, 1, 4, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; = 0 Or IsNull(SUPStatus)), 1, 0) As Flag1,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then use &lt;/P&gt;&lt;P&gt;&lt;EM&gt;=Sum({&amp;lt;Flag1 = {1}&amp;gt;} &lt;EM style="font-size: 13.3333px;"&gt;[SUP#])&lt;/EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Nov 2015 09:41:04 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2015-11-09T09:41:04Z</dc:date>
    <item>
      <title>nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960776#M956474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to calculate the following but cant get it to work.&lt;/P&gt;&lt;P&gt;I'm trying to say that if field A = 'ContractRef' and SUPStatus field is not&amp;nbsp; 1,4,8, then sum the SUP field otherwise its 0.&amp;nbsp; I also need to include NULLS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I have tried (any many more things) so far:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=If( [ConType]='ContractRef' AND [SUPStatus] = 1) OR [ConType]='ContractRef' AND [SUPStatus] = 4) OR&lt;/P&gt;&lt;P&gt;[ConType]='ContractRef' AND [SUPStatus] = 8),0,sum([SUP#])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any help appreciated.&amp;nbsp; also if you have examples that can help me learn to write these scripts better please let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Laura&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 08:19:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960776#M956474</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-09T08:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960777#M956475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&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: 13px;"&gt;IF(field A = 'ContractRef' and SUPStatus &amp;lt;&amp;gt;1 or &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SUPStatus &amp;lt;&amp;gt;&lt;/SPAN&gt;4,&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;or &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SUPStatus &amp;lt;&amp;gt;&lt;/SPAN&gt;8 ,sum(SUP))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 08:24:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960777#M956475</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-09T08:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960778#M956476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might want to check out the MATCH() and MIXMATCH() functions &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 08:43:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960778#M956476</guid>
      <dc:creator>richard_chilvers</dc:creator>
      <dc:date>2015-11-09T08:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960779#M956477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;it wont pick up the NULLs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 08:46:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960779#M956477</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-09T08:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960780#M956478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suggest using a MAP to replace the NULLs with 0 and then use ApplyMap to replace NULL values of SUP with 0. Your SUM() should be able to take care of the NULLs in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ZeroMap:&lt;/P&gt;&lt;P&gt;MAPPING LOAD *inline [&lt;/P&gt;&lt;P&gt;null(), '0'&lt;/P&gt;&lt;P&gt;NULL,'0'&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num(ApplyMap('ZeroMap',&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SUP&lt;/SPAN&gt;),'#,##0.00;(#,##0.00)') as &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SUP&lt;/SPAN&gt;, &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 08:59:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960780#M956478</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-09T08:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960781#M956479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Hi Laura,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Try the below one,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If([ConType]=''ContractRef' and Not Match([SUPStatus],1,4,8),sum([SUP#],0)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Not sure, in which field you want to add null. Could you elaborate.?&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 09:30:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960781#M956479</guid>
      <dc:creator>tamilarasu</dc:creator>
      <dc:date>2015-11-09T09:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960782#M956480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its obvious, it wont pick, if you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do like this:&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: 13px;"&gt;IF(field A = 'ContractRef'&amp;nbsp; and &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;fieldA=null() &lt;/SPAN&gt;and SUPStatus &amp;lt;&amp;gt;1 or &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SUPStatus &amp;lt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;4,&lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;or &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SUPStatus &amp;lt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;8,&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;or &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SUPStatus=null()&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;,sum(SUP))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can rectify it as per your requirement...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 09:34:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960782#M956480</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-09T09:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960783#M956481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This should work&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=Sum(If((ConType = ContractRef Or IsNull(ConType)) And (Match(SUPStatus, 1, 4, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; = 0 Or IsNull(SUPStatus)), [SUP#]))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Set analysis usually performs much better than a sum(if()) structure, but it is not so easy to include nulls (just as it is not possible to select nulls in the front end). So i suggest that you post a sample qvw file for more detailed analysis. Or you can set a flag at load time and use that in a set expression. Something like:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...If((ConType = ContractRef Or IsNull(ConType)) And (Match(SUPStatus, 1, 4, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; = 0 Or IsNull(SUPStatus)), 1, 0) As Flag1,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then use &lt;/P&gt;&lt;P&gt;&lt;EM&gt;=Sum({&amp;lt;Flag1 = {1}&amp;gt;} &lt;EM style="font-size: 13.3333px;"&gt;[SUP#])&lt;/EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 09:41:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960783#M956481</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2015-11-09T09:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: nested if and sum statement in the Expression</title>
      <link>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960784#M956482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;sum(if(&lt;EM&gt;[ConType]=''ContractRef' and Match([SUPStatus],1,4,8)=0&lt;/EM&gt;,&lt;EM&gt;SUP#&lt;/EM&gt;))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 09:55:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/nested-if-and-sum-statement-in-the-Expression/m-p/960784#M956482</guid>
      <dc:creator>jafari_ervin</dc:creator>
      <dc:date>2015-11-09T09:55:15Z</dc:date>
    </item>
  </channel>
</rss>

