<?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 SUM IF executing multiple times in expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SUM-IF-executing-multiple-times-in-expression/m-p/1708215#M455609</link>
    <description>&lt;P&gt;I'm puzzled by the logic being executed in&amp;nbsp; an expression when two snippets of code are used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, if I run this piece of code, it returns 1, as expected:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=SUM(
	IF(false(),
	1,
	1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I modify the formula slightly and replace the success variable to be summed with an actual field, the formula returns 24 which happens to be the count of the field as well:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=SUM(
	IF(false(),
	myField,
	1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone understand why this is happening and how can I get around it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 00:32:29 GMT</pubDate>
    <dc:creator>SamQlik</dc:creator>
    <dc:date>2024-11-16T00:32:29Z</dc:date>
    <item>
      <title>SUM IF executing multiple times in expression</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-IF-executing-multiple-times-in-expression/m-p/1708215#M455609</link>
      <description>&lt;P&gt;I'm puzzled by the logic being executed in&amp;nbsp; an expression when two snippets of code are used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, if I run this piece of code, it returns 1, as expected:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=SUM(
	IF(false(),
	1,
	1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I modify the formula slightly and replace the success variable to be summed with an actual field, the formula returns 24 which happens to be the count of the field as well:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=SUM(
	IF(false(),
	myField,
	1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone understand why this is happening and how can I get around it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:32:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-IF-executing-multiple-times-in-expression/m-p/1708215#M455609</guid>
      <dc:creator>SamQlik</dc:creator>
      <dc:date>2024-11-16T00:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: SUM IF executing multiple times in expression</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-IF-executing-multiple-times-in-expression/m-p/1708223#M455610</link>
      <description>&lt;P&gt;Presumably, the first expression is evaluating once because it's just an empty function, while the second expression is evaluating once per myField value, so 24 times.&lt;/P&gt;&lt;P&gt;It sounds like what you're after is actually:&lt;/P&gt;&lt;P&gt;If(False(),Sum(Myfield),1)&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 14:06:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-IF-executing-multiple-times-in-expression/m-p/1708223#M455610</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2020-06-04T14:06:15Z</dc:date>
    </item>
  </channel>
</rss>

