<?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 Sets vs if statements in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298947#M500936</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why does the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; = Count({$&amp;lt;[PFI ID] = {'$(vPFI_blank)'}&amp;gt;} UniqueID) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;returns a different result than:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; = Count(if [PFI ID] = $(vPFI_blank), UniqueID) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first returns the correct result while the second one doesn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 May 2011 19:50:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-05-13T19:50:36Z</dc:date>
    <item>
      <title>Sets vs if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298947#M500936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why does the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; = Count({$&amp;lt;[PFI ID] = {'$(vPFI_blank)'}&amp;gt;} UniqueID) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;returns a different result than:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; = Count(if [PFI ID] = $(vPFI_blank), UniqueID) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first returns the correct result while the second one doesn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 19:50:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298947#M500936</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-05-13T19:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sets vs if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298948#M500937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe these are equivalent.&amp;nbsp; Neither matches your current expressions, but I believe are what you are attempting to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;count({&amp;lt;[PFI ID]*={'$(vPFI_blank)'}&amp;gt;} UniqueID)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;count(if([PFI ID]=vPFI_blank,UniqueID))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the first expression, when you do [PFI ID]= in set analysis, this is an OVERRIDE.&amp;nbsp; It overrides your selections and picks ALL the values in the set.&amp;nbsp; Using if(), on the other hand is INTERSECTION.&amp;nbsp; You get the intersection of the selected values and the values in the if().&amp;nbsp; An if() cannot be converted to an override, but set analysis can be converted to an intersection by using *=.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the second expression, you had a syntax error where you were missing parentheses on the if().&amp;nbsp; Also, keep in mind that $() is dollar sign expansion, and will literally insert the value into the expression.&amp;nbsp; If the value is something like Hello World, you'd end up with [PFI ID] = Hello World, which is a syntax error because string literals must be enclosed in single quotes.&amp;nbsp; You could enclose it in single quotes just like you did in the set analysis, but in the if(), I believe it is valid to simply remove the $() and check the variable value directly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 20:07:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298948#M500937</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-05-13T20:07:52Z</dc:date>
    </item>
    <item>
      <title>Sets vs if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298949#M500938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, John.&amp;nbsp; Thanks for the prompt reply.&amp;nbsp; I was quickly typing the syntax I was using before but here is a bit more detail:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Nothing is selected, the data is broken down by month and year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) The formula: &lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Count({$&amp;lt;[PFI ID] = {'$(vPFI_blank)'}&amp;gt;} UniqueID)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returns 3,112 (the correct answer)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) The formula:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =count( if([PFI ID] = vPFI_blank,UniqueID))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returns 3,266 (an incorrect answer)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿I've been fighting this for the past day.&amp;nbsp; Does it make any sense?&amp;nbsp; What am I not seeing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;-- Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 21:46:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298949#M500938</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-05-13T21:46:26Z</dc:date>
    </item>
    <item>
      <title>Sets vs if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298950#M500939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not seeing it.&amp;nbsp; As long as nothing is selected, those look equivalent to me.&amp;nbsp; One issue would be if UniqueID is a field on more than one table, though I'd honestly then expect both expressions to return equally wrong results.&amp;nbsp; Can you post an example demonstrating the problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 21:52:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298950#M500939</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-05-13T21:52:14Z</dc:date>
    </item>
    <item>
      <title>Sets vs if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298951#M500940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, John.&amp;nbsp; Just wanted to get back to you.&amp;nbsp; I ended up getting to the answer a different way.&amp;nbsp; I was building a stacked line chart with two lines - 1 for items with a PFI ID and the other for items without a PFI ID.&amp;nbsp; I was doing this by setting up metrics / expressions as noted above.&amp;nbsp; It turns out, however, that I could get the correct response just by using a simple count (UniqueID) as the expression and building a calculated dimension &lt;EM&gt;=if([PFI ID]=vPFI_blank, 'No PFI', 'w PFI').&lt;/EM&gt;&amp;nbsp; This solved the problem and seems to perform a bit faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyhow, I just didn't want to leave this hanging.&amp;nbsp; I'm not sure what caused the earlier problem but, at least, my testing turned it up.&amp;nbsp; Thanks again for your help!&lt;/P&gt;&lt;P&gt;-- Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 14:40:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sets-vs-if-statements/m-p/298951#M500940</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-05-17T14:40:45Z</dc:date>
    </item>
  </channel>
</rss>

