<?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: Another approach to implement Count distinct in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1653905#M48857</link>
    <description>&lt;P&gt;Hi Sandeep,&lt;/P&gt;&lt;P&gt;Thanks for sharing your new approach. Without much diving deep into your approach, I too am not really sure if this would be faster or not. However, I would say and highlight that it is a&amp;nbsp;&lt;STRONG&gt;myth&lt;/STRONG&gt;&amp;nbsp;now. This count distinct operation used to be single-threaded, but that is long back; today it is &lt;STRONG&gt;multi-threaded.&lt;/STRONG&gt; Please check this :&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/A-Myth-About-Count-distinct/ba-p/1476053" target="_self"&gt;A Myth About Count(distinct …) &lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, without discouraging your effort I would say - you should not be much worried about using using count(distinct...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate that you thought of some new approach..&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Dec 2019 06:31:01 GMT</pubDate>
    <dc:creator>tresB</dc:creator>
    <dc:date>2019-12-04T06:31:01Z</dc:date>
    <item>
      <title>Another approach to implement Count distinct</title>
      <link>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1653893#M48855</link>
      <description>&lt;P&gt;I have implemented count distinct in a bit different way. Not sure if this will result in better performance or not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In script load I used autonumber(Field1,"Type1") as _Key. Then I can get the max of that _Key using peek. I create another table populating it with 2 fields .&lt;/P&gt;&lt;P&gt;LET TtlNum = Peek('_Key',-1, 'TMP');&lt;BR /&gt;LET Start = 1;&lt;/P&gt;&lt;P&gt;Table1:&lt;BR /&gt;LOAD&lt;BR /&gt;$(Start) + Rowno() -1 as [_Key],&lt;BR /&gt;1 as Field2&lt;BR /&gt;AUTOGENERATE $(TtlNum);&lt;/P&gt;&lt;P&gt;Now in my data model these 2 tables will join on _Key and instead of using count(distinct _Key) I can use sum(Field2) in my expressions. Since I will not be using distinct in my expressions so I am hoping this should be faster.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 19:31:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1653893#M48855</guid>
      <dc:creator>sandeepgather</dc:creator>
      <dc:date>2024-11-16T19:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Another approach to implement Count distinct</title>
      <link>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1653905#M48857</link>
      <description>&lt;P&gt;Hi Sandeep,&lt;/P&gt;&lt;P&gt;Thanks for sharing your new approach. Without much diving deep into your approach, I too am not really sure if this would be faster or not. However, I would say and highlight that it is a&amp;nbsp;&lt;STRONG&gt;myth&lt;/STRONG&gt;&amp;nbsp;now. This count distinct operation used to be single-threaded, but that is long back; today it is &lt;STRONG&gt;multi-threaded.&lt;/STRONG&gt; Please check this :&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/A-Myth-About-Count-distinct/ba-p/1476053" target="_self"&gt;A Myth About Count(distinct …) &lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, without discouraging your effort I would say - you should not be much worried about using using count(distinct...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate that you thought of some new approach..&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 06:31:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1653905#M48857</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2019-12-04T06:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Another approach to implement Count distinct</title>
      <link>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654077#M48865</link>
      <description>&lt;P&gt;It's an interesting and clever approach, but appears to be more complex than necessary.&amp;nbsp; Could you skip the AutoNumber and do instead:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;KeyCounters:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;LOAD FieldValue('Key', RecNo()) as Key,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1 as KeyCounter&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AutoGenerate FieldValueCount('Key');&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;and then&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sum(KeyCounter)&amp;nbsp;&lt;BR /&gt;or Count(KeyCounter) -- which might be faster than Sum&lt;/P&gt;&lt;P&gt;-Rob&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 13:01:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654077#M48865</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2019-12-04T13:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Another approach to implement Count distinct</title>
      <link>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654361#M48894</link>
      <description>&lt;P&gt;Thanks Tresesco and Rob!!!&lt;/P&gt;&lt;P&gt;This works well also. Only reason I put&amp;nbsp; autonumber was that my key is combination of string elements.&lt;/P&gt;&lt;P&gt;Question still though is whether this approach of getting distinct count be faster then using the actual distinct in expression.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 22:21:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654361#M48894</guid>
      <dc:creator>sandeepgather</dc:creator>
      <dc:date>2019-12-04T22:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Another approach to implement Count distinct</title>
      <link>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654376#M48895</link>
      <description>&lt;P&gt;I would think that it *may* be marginally faster with large data volumes and in situations with concatenated strings as keys, but the only way to know for sure would be to test it. If I'm understanding your solution correctly you are introducing another table so there's a hop between tables introduced which may have a small overhead. Henric Cronstrom wrote an article on the impact of hops years ago (&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/A-Myth-about-the-Number-of-Hops/bc-p/1474641#M6844" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/A-Myth-about-the-Number-of-Hops/bc-p/1474641#M6844&lt;/A&gt;) but that was before the more recent version of the engine was developed and it may well perform differently.&lt;/P&gt;&lt;P&gt;If you do get a chance to test it out I'm sure many would be keen to know the results! Thanks for an interesting post.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 23:30:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654376#M48895</guid>
      <dc:creator>Rodj</dc:creator>
      <dc:date>2019-12-04T23:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Another approach to implement Count distinct</title>
      <link>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654383#M48896</link>
      <description>&lt;P&gt;If you don't need to display the keys as data consider using the new AutoNumber script statement to reduce your RAM usage.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;AutoNumber Key;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The count distinct question has some complexities. Perhaps I'll write a blog post about it...&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 00:44:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Another-approach-to-implement-Count-distinct/m-p/1654383#M48896</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2019-12-05T00:44:56Z</dc:date>
    </item>
  </channel>
</rss>

