<?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: Count, IF and Distinct Query Syntax in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979337#M646997</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;Count(Distinct IF(POTCode = '23', IDKey&amp;amp; ServiceDate))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Oct 2015 13:57:37 GMT</pubDate>
    <dc:creator>MK_QSL</dc:creator>
    <dc:date>2015-10-01T13:57:37Z</dc:date>
    <item>
      <title>Count, IF and Distinct Query Syntax</title>
      <link>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979336#M646996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Need scripting help with an Expression.&amp;nbsp; I need to count DISTINCT based on two fields, but now I need to add an IF as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I need to count the number of DISTINCT events (defined by combination of &lt;STRONG style="text-decoration: underline;"&gt;IDKEY&lt;/STRONG&gt; and &lt;STRONG style="text-decoration: underline;"&gt;ServiceDate&lt;/STRONG&gt;) IF the &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;POTCode&lt;/STRONG&gt;&lt;/SPAN&gt; is 23.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far, I have tried numerous combinations.&amp;nbsp; The following are a couple examples, but none of them work.&amp;nbsp; Can someone please help me with the syntax?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;IF(POTCode = '23', Count(DISTINCT IDKey&amp;amp; ServiceDate))&amp;nbsp; --- I get no results with this one.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Count({$&amp;lt;POTCode={"23"}&amp;gt;}DISTINCT IDKey &amp;amp; ServiceDate) --The totals are not correct as it is still pulling other POT codes and repeat ServiceDates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Oct 2015 13:48:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979336#M646996</guid>
      <dc:creator />
      <dc:date>2015-10-01T13:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Count, IF and Distinct Query Syntax</title>
      <link>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979337#M646997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;Count(Distinct IF(POTCode = '23', IDKey&amp;amp; ServiceDate))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Oct 2015 13:57:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979337#M646997</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-10-01T13:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count, IF and Distinct Query Syntax</title>
      <link>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979338#M646998</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;maybe there is an easier way, but you could create a new field out of IDKEY and ServiceDate and then you could count the distinct values of this field. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KR&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Oct 2015 13:59:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979338#M646998</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2015-10-01T13:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Count, IF and Distinct Query Syntax</title>
      <link>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979339#M646999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Better way is to create a key from combination of IDKey &amp;amp; ServiceDate..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AutoNumber(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;IDKey&amp;amp; ServiceDate) as Key&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: 13.3333px;"&gt;&lt;BR /&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: 13.3333px;"&gt;Now you can use&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: 13.3333px;"&gt;Count(Distinct If(POTCode = '23', Key))&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Oct 2015 14:01:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-IF-and-Distinct-Query-Syntax/m-p/979339#M646999</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-10-01T14:01:55Z</dc:date>
    </item>
  </channel>
</rss>

