<?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: Find the distinct count using count if in Search the Community</title>
    <link>https://community.qlik.com/t5/Search-the-Community/Find-the-distinct-count-using-count-if/m-p/1830233#M495</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/147970"&gt;@sudms&lt;/a&gt;&amp;nbsp; best way to do it is create a flag in script for the required conditions and use that flag in expression to get the count&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;LOAD Category,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SubCat,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(len(trim(SubCat))&amp;gt;0 and SubCat&amp;lt;&amp;gt;Category,1,0) as Flag,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ID&lt;BR /&gt;FROM Table;&lt;/P&gt;&lt;P&gt;Now, create a expression like below&lt;/P&gt;&lt;P&gt;=Count({&amp;lt;Flag={1}&amp;gt;}DISTINCT ID)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Aug 2021 14:16:25 GMT</pubDate>
    <dc:creator>Kushal_Chawda</dc:creator>
    <dc:date>2021-08-20T14:16:25Z</dc:date>
    <item>
      <title>Find the distinct count using count if</title>
      <link>https://community.qlik.com/t5/Search-the-Community/Find-the-distinct-count-using-count-if/m-p/1830225#M494</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to get the total distinct count from below table.&lt;/P&gt;&lt;T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t;&lt;TR&gt;&lt;TD&gt;Chat&lt;/TD&gt;&lt;TD&gt;Email&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Chat&lt;/TD&gt;&lt;TD&gt;Email&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Chat&lt;/TD&gt;&lt;TD&gt;Other&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Chat&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ACS&lt;/TD&gt;&lt;TD&gt;Other&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here if you see I have two conditions like&lt;/P&gt;&lt;P&gt;1&amp;gt; SubCat should not be null&lt;/P&gt;&lt;P&gt;2&amp;gt; Category and SubCat should not match&lt;/P&gt;&lt;P&gt;With this I want the single value in my KPI of distinct count 5. I tried with below query but it gives 6 for the Aggr.&lt;/P&gt;&lt;P&gt;Sum(Aggr(IF(Len(SubCat)&amp;gt;0 and SubCat&amp;lt;&amp;gt;Category, count(distinct ID)),SubCat,Category))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any solution to get the answer.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 13:48:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Search-the-Community/Find-the-distinct-count-using-count-if/m-p/1830225#M494</guid>
      <dc:creator>sudms</dc:creator>
      <dc:date>2021-08-20T13:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find the distinct count using count if</title>
      <link>https://community.qlik.com/t5/Search-the-Community/Find-the-distinct-count-using-count-if/m-p/1830233#M495</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/147970"&gt;@sudms&lt;/a&gt;&amp;nbsp; best way to do it is create a flag in script for the required conditions and use that flag in expression to get the count&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;LOAD Category,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SubCat,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(len(trim(SubCat))&amp;gt;0 and SubCat&amp;lt;&amp;gt;Category,1,0) as Flag,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ID&lt;BR /&gt;FROM Table;&lt;/P&gt;&lt;P&gt;Now, create a expression like below&lt;/P&gt;&lt;P&gt;=Count({&amp;lt;Flag={1}&amp;gt;}DISTINCT ID)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 14:16:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Search-the-Community/Find-the-distinct-count-using-count-if/m-p/1830233#M495</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2021-08-20T14:16:25Z</dc:date>
    </item>
  </channel>
</rss>

