<?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 aggr distinct dimension conditionally in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-aggr-distinct-dimension-conditionally/m-p/1255655#M396835</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! That works perfectly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Dec 2016 18:56:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-12-13T18:56:05Z</dc:date>
    <item>
      <title>Count aggr distinct dimension conditionally</title>
      <link>https://community.qlik.com/t5/QlikView/Count-aggr-distinct-dimension-conditionally/m-p/1255653#M396833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to create an expression in a table that counts the number of Policies by Region that have a rating of 'Red' for Policy Health.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;A Policy is classified as 'Red' if its Policy Health is &amp;gt;25. The only dimension in the table is Region.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the same table, we calculate the Policy Health using the following calc:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({1*&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Disabled&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'No'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Run Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'$(=max([Run Date]))'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Firewall Type]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'Border'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Connection Count]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[SIM Score]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)&lt;BR /&gt; /&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({1*&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Disabled&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'No'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Run Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'$(=max([Run Date]))'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Firewall Type]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'Border'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Connection Count]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The above expression works fine. The below is what I've tried to count distinct 'Red' Policies per Region:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;distinct&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({1*&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Disabled&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'No'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Run Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'$(=max([Run Date]))'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Firewall Type]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'Border'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Connection Count]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[SIM Score]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)&lt;BR /&gt; /&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({1*&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Disabled&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'No'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Run Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'$(=max([Run Date]))'},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Firewall Type]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {'Border'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Connection Count]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))&amp;gt;25,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Policy&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;but no luck. I have also tried some aggr() functions but again can't crack this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 18:04:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-aggr-distinct-dimension-conditionally/m-p/1255653#M396833</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-13T18:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count aggr distinct dimension conditionally</title>
      <link>https://community.qlik.com/t5/QlikView/Count-aggr-distinct-dimension-conditionally/m-p/1255654#M396834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum(Aggr(&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If((Sum({1*&amp;lt;Disabled = {'No'}, [Run Date] = {'$(=Max([Run Date]))'}, [Firewall Type] = {'Border'}&amp;gt;} [Connection Count] * [SIM Score])/Sum({1*&amp;lt;Disabled = {'No'}, [Run Date] = {'$(=Max([Run Date]))'}, [Firewall Type] = {'Border'}&amp;gt;} [Connection Count])) &amp;gt; 25&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;, 1, 0), Policy, Region))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 18:52:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-aggr-distinct-dimension-conditionally/m-p/1255654#M396834</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-12-13T18:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Count aggr distinct dimension conditionally</title>
      <link>https://community.qlik.com/t5/QlikView/Count-aggr-distinct-dimension-conditionally/m-p/1255655#M396835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! That works perfectly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 18:56:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-aggr-distinct-dimension-conditionally/m-p/1255655#M396835</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-13T18:56:05Z</dc:date>
    </item>
  </channel>
</rss>

