<?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 Scripting / Expression assistance with Count Distinct in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Scripting-Expression-assistance-with-Count-Distinct/m-p/1681726#M727411</link>
    <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;In my model I am reading a 'main' table, and 3 subsequent other tables.&lt;/P&gt;&lt;P&gt;Now, a record can exists in &lt;STRONG&gt;one&lt;/STRONG&gt; of these 3 tables, or &lt;STRONG&gt;two&lt;/STRONG&gt;, &lt;STRONG&gt;three&lt;/STRONG&gt;, or &lt;STRONG&gt;none&lt;/STRONG&gt; at all.&lt;/P&gt;&lt;P&gt;if it exists in &lt;STRONG&gt;at least one table, &lt;/STRONG&gt;I want to count the distinct value ONCE only&lt;STRONG&gt; .&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;in other words, if count distinct (field) = 0, value returns 0, ELSE return &lt;STRONG&gt;ONLY&lt;/STRONG&gt; 1.&lt;/P&gt;&lt;P&gt;My problem is, if I count the distinct value in my expression (which exists in 2 of these tables), it ONLY gets the right answer if Customer is a dimension in the table. If I remove the Customer column, it gets incorrect value.&lt;/P&gt;&lt;P&gt;Please assist - might be better doing this in the script? I dont want to join the tables, since later on, I need to add more details to the model and then a join might not work like I want it to.&lt;/P&gt;&lt;P&gt;(Data has been scrambled for security)&lt;/P&gt;&lt;P&gt;Much appreciated&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 01:08:00 GMT</pubDate>
    <dc:creator>QFanatic</dc:creator>
    <dc:date>2024-11-16T01:08:00Z</dc:date>
    <item>
      <title>Scripting / Expression assistance with Count Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-Expression-assistance-with-Count-Distinct/m-p/1681726#M727411</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;In my model I am reading a 'main' table, and 3 subsequent other tables.&lt;/P&gt;&lt;P&gt;Now, a record can exists in &lt;STRONG&gt;one&lt;/STRONG&gt; of these 3 tables, or &lt;STRONG&gt;two&lt;/STRONG&gt;, &lt;STRONG&gt;three&lt;/STRONG&gt;, or &lt;STRONG&gt;none&lt;/STRONG&gt; at all.&lt;/P&gt;&lt;P&gt;if it exists in &lt;STRONG&gt;at least one table, &lt;/STRONG&gt;I want to count the distinct value ONCE only&lt;STRONG&gt; .&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;in other words, if count distinct (field) = 0, value returns 0, ELSE return &lt;STRONG&gt;ONLY&lt;/STRONG&gt; 1.&lt;/P&gt;&lt;P&gt;My problem is, if I count the distinct value in my expression (which exists in 2 of these tables), it ONLY gets the right answer if Customer is a dimension in the table. If I remove the Customer column, it gets incorrect value.&lt;/P&gt;&lt;P&gt;Please assist - might be better doing this in the script? I dont want to join the tables, since later on, I need to add more details to the model and then a join might not work like I want it to.&lt;/P&gt;&lt;P&gt;(Data has been scrambled for security)&lt;/P&gt;&lt;P&gt;Much appreciated&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:08:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-Expression-assistance-with-Count-Distinct/m-p/1681726#M727411</guid>
      <dc:creator>QFanatic</dc:creator>
      <dc:date>2024-11-16T01:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting / Expression assistance with Count Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-Expression-assistance-with-Count-Distinct/m-p/1681745#M727412</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm not sure, but have you tried to use aggr?&lt;/P&gt;&lt;P&gt;Like this&lt;/P&gt;&lt;P&gt;=Sum(Aggr(if(RangeSUM(PROFILE_MOBI,PROFILE_OL,PROFILE_BA) &amp;gt; 0,&lt;BR /&gt;IF(CUS_TYPE_MOBI= 'ZOB' OR CUS_TYPE_OL= 'ZOB' OR CUS_TYPE_BA= 'ZOB',&lt;BR /&gt;COUNT({&amp;lt;CO_CDE = {'15'}&amp;gt;} distinct CUSTOMERS)&lt;BR /&gt;)&lt;BR /&gt;),CUSTOMERS,PERIOD))&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 16:04:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-Expression-assistance-with-Count-Distinct/m-p/1681745#M727412</guid>
      <dc:creator>StarinieriG</dc:creator>
      <dc:date>2020-03-04T16:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting / Expression assistance with Count Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Scripting-Expression-assistance-with-Count-Distinct/m-p/1681907#M727413</link>
      <description>&lt;P&gt;Thank you - it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 05:54:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Scripting-Expression-assistance-with-Count-Distinct/m-p/1681907#M727413</guid>
      <dc:creator>QFanatic</dc:creator>
      <dc:date>2020-03-05T05:54:11Z</dc:date>
    </item>
  </channel>
</rss>

