<?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 Count distinct with group by in the script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Count-distinct-with-group-by-in-the-script/m-p/1907884#M74828</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is a sample of what I am trying to do to count distinct two fields using the group by.&lt;/P&gt;
&lt;P&gt;First I know that this is very easy to be done in the chart side and not in the script but I am obliged to do it from the script because I have billions of record that makes my dashboard very huge and slow in performance and in my current dashboard all I want is the aggregation grouped by the dimensions below and if I am not doing any filter using below dimension to get the total of these 2 kpis and to be distinct.&lt;/P&gt;
&lt;P&gt;For example the below result should show :&lt;/P&gt;
&lt;P&gt;[KPI Value Customer] = 2 (C1 and C2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[KPI Value Player Days] = 5 (P101&amp;nbsp;,P102&amp;nbsp;,P103 ,&amp;nbsp;P201&amp;nbsp;,P202&amp;nbsp;)&lt;/P&gt;
&lt;P&gt;and let's say in the dashboard we filtered brand = 3 the KPIs should show&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[KPI Value Customer] = 2 (C1 and C2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[KPI Value Player Days] = 3 (P103 ,&amp;nbsp;P201&amp;nbsp;,P202&amp;nbsp;)&lt;/P&gt;
&lt;P&gt;testTable:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;year&amp;nbsp; , Datemk&amp;nbsp; ,&amp;nbsp; customer , playerdays , brand , provider , customermarket&lt;BR /&gt;2022 ,01032022, &lt;STRONG&gt;C1&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P101&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cust1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;2022 ,02032022, &lt;STRONG&gt;C1&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P102&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;2022 ,03032022, &lt;STRONG&gt;C1&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P103&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;2022 ,03032022, &lt;STRONG&gt;C2&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P201&lt;/STRONG&gt;&amp;nbsp;,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;2022 ,04032022, &lt;STRONG&gt;C2&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P202&lt;/STRONG&gt;&amp;nbsp;,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;GroupingTable: &lt;BR /&gt;Load brand,year,customermarket,provider, kpiname,&lt;BR /&gt;'MTD' as [Period],&lt;BR /&gt;count(DISTINCT (playerdays)) as [KPI Value Player Days] ,&lt;BR /&gt;count(DISTINCT (customer)) as [KPI Value Customer] &lt;BR /&gt;resident testTable&lt;BR /&gt;group by brand,year,customermarket,provider;&lt;/P&gt;
&lt;P&gt;Drop Table testTable;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for your support and suggestions.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2022 20:45:59 GMT</pubDate>
    <dc:creator>EISSA</dc:creator>
    <dc:date>2022-03-21T20:45:59Z</dc:date>
    <item>
      <title>Count distinct with group by in the script</title>
      <link>https://community.qlik.com/t5/App-Development/Count-distinct-with-group-by-in-the-script/m-p/1907884#M74828</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is a sample of what I am trying to do to count distinct two fields using the group by.&lt;/P&gt;
&lt;P&gt;First I know that this is very easy to be done in the chart side and not in the script but I am obliged to do it from the script because I have billions of record that makes my dashboard very huge and slow in performance and in my current dashboard all I want is the aggregation grouped by the dimensions below and if I am not doing any filter using below dimension to get the total of these 2 kpis and to be distinct.&lt;/P&gt;
&lt;P&gt;For example the below result should show :&lt;/P&gt;
&lt;P&gt;[KPI Value Customer] = 2 (C1 and C2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[KPI Value Player Days] = 5 (P101&amp;nbsp;,P102&amp;nbsp;,P103 ,&amp;nbsp;P201&amp;nbsp;,P202&amp;nbsp;)&lt;/P&gt;
&lt;P&gt;and let's say in the dashboard we filtered brand = 3 the KPIs should show&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[KPI Value Customer] = 2 (C1 and C2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[KPI Value Player Days] = 3 (P103 ,&amp;nbsp;P201&amp;nbsp;,P202&amp;nbsp;)&lt;/P&gt;
&lt;P&gt;testTable:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;year&amp;nbsp; , Datemk&amp;nbsp; ,&amp;nbsp; customer , playerdays , brand , provider , customermarket&lt;BR /&gt;2022 ,01032022, &lt;STRONG&gt;C1&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P101&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cust1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;2022 ,02032022, &lt;STRONG&gt;C1&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P102&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust1 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;2022 ,03032022, &lt;STRONG&gt;C1&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P103&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;2022 ,03032022, &lt;STRONG&gt;C2&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P201&lt;/STRONG&gt;&amp;nbsp;,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;2022 ,04032022, &lt;STRONG&gt;C2&lt;/STRONG&gt; ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;P202&lt;/STRONG&gt;&amp;nbsp;,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pr3 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cust2 ,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;GroupingTable: &lt;BR /&gt;Load brand,year,customermarket,provider, kpiname,&lt;BR /&gt;'MTD' as [Period],&lt;BR /&gt;count(DISTINCT (playerdays)) as [KPI Value Player Days] ,&lt;BR /&gt;count(DISTINCT (customer)) as [KPI Value Customer] &lt;BR /&gt;resident testTable&lt;BR /&gt;group by brand,year,customermarket,provider;&lt;/P&gt;
&lt;P&gt;Drop Table testTable;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for your support and suggestions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 20:45:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Count-distinct-with-group-by-in-the-script/m-p/1907884#M74828</guid>
      <dc:creator>EISSA</dc:creator>
      <dc:date>2022-03-21T20:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Count distinct with group by in the script</title>
      <link>https://community.qlik.com/t5/App-Development/Count-distinct-with-group-by-in-the-script/m-p/1907911#M74833</link>
      <description>&lt;P&gt;Your script looks like it should work. Except there should be no () around the fieldname in Count.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;count(DISTINCT playerdays)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-Rob&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 22:58:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Count-distinct-with-group-by-in-the-script/m-p/1907911#M74833</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2022-03-21T22:58:52Z</dc:date>
    </item>
  </channel>
</rss>

