<?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: Distinct Count and Aggregation in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651017#M1065880</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;not clear logic in your expecting result, why Deal 100 has no data for Q1?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Sep 2014 19:25:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-09-19T19:25:38Z</dc:date>
    <item>
      <title>Distinct Count and Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651016#M1065879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have the following data set&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="224" style="width: 253px; height: 215px; border: #000000 1px solid;" width="251"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Deal&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Quarter&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;50000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-5000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 101&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;26000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 102&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;47000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 102&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 103&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Q4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7800&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to display it as follows&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="149" style="BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; WIDTH: 418px; HEIGHT: 137px; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Deal&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Q1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Q2&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Q3&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Q4&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;45220&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 101&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;26000&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 102&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;47500&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal 103&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7800&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Deal Count&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, I want to count deal just once even though it books across multiple quarters and aggregate the amount in the quarter that has the biggest chunk of the booking.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;CD&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 19:07:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651016#M1065879</guid>
      <dc:creator>chiranjivdas</dc:creator>
      <dc:date>2014-09-19T19:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count and Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651017#M1065880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;not clear logic in your expecting result, why Deal 100 has no data for Q1?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 19:25:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651017#M1065880</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-19T19:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count and Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651018#M1065881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because thats how i want it to be.... a deal should appear only once... in the quarter that has the biggest dollar amount... deal 100 has the biggest dollar amount of 50000 in Q3... so it should show up in Q3 as aggregate: 20 + 200 + 50000 - 5000 = 45220.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 20:36:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651018#M1065881</guid>
      <dc:creator>chiranjivdas</dc:creator>
      <dc:date>2014-09-19T20:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count and Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651019#M1065882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" src="https://community.qlik.com/legacyfs/online/67249_pastedImage_0.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The key to the solution is that for each Deal, identify a Quarter that has received highest Amount.&lt;/P&gt;&lt;P&gt;This expression in Pivot table does the horse work.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;if(min(Aggr(rank(Amount),Deal,Quarter))=1, Aggr(Sum(Total &amp;lt;Deal&amp;gt; Amount),Deal,Quarter))&lt;/P&gt;



&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The first part of the expression ranks highest amount. Each Quarter in the Deal will receive a rank which is than checked in 'if' condition whether it is minimum (=1). If the check returns true, it means we are now able to point towards correct Quarter (that holds highest amount) in the Deal.&lt;/P&gt;&lt;P&gt;So then we decide to calculate the Total amount.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the chart properties/Presentation tab, it is required to uncheck 'Suppress Zero values' so that Q1 column is shown as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, I couldn't figure out how to get Deal count at the bottom of Pivot table. (though it can be done in straight table, you would have to sacrifice the cross-table design which is not possible in straight table)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the attached application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;Kalpesh Jain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 21:12:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651019#M1065882</guid>
      <dc:creator />
      <dc:date>2014-09-19T21:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count and Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651020#M1065883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;=&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(count(TOTAL &amp;lt;Deal&amp;gt; Amount)=1, sum(Amount),&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(max(total &amp;lt;Deal&amp;gt; aggr(sum(Amount),Deal,Quarter))=sum(Amount), sum(TOTAL &amp;lt;Deal&amp;gt; Amount) ))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/67253_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 21:32:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651020#M1065883</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-09-19T21:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count and Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651021#M1065885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks... both solutions work. But now as I looked into the data set more, I realized I need to 'cleanse' the data at the time of the load. So if a deal has dollar amounts spread over multiple quarters, I want to include a load script that will identify the first quarter that it ever booked in and aggregate the amount in that quarter. For example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deal 100&lt;/P&gt;&lt;P&gt;Q1: 20&lt;/P&gt;&lt;P&gt;Q2: 200&lt;/P&gt;&lt;P&gt;Q3: 50000&lt;/P&gt;&lt;P&gt;Q4: -5000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the script load to pick up 45220 in Q1. Is there a conditional script that I can insert in the load statement to achieve this? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 23:22:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651021#M1065885</guid>
      <dc:creator>chiranjivdas</dc:creator>
      <dc:date>2014-09-19T23:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count and Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651022#M1065886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just append this to the existing load statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Left Join(Deals)&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Deal, MinString(Quarter) as [Quarter],&lt;/P&gt;&lt;P&gt;sum(Amount) as [Total Amount]&lt;/P&gt;&lt;P&gt;Resident Deals&lt;/P&gt;&lt;P&gt;Group by Deal;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="67255" alt="" class="jiveImage" src="https://community.qlik.com/legacyfs/online/67255_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Kalpesh Jain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2014 08:33:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Distinct-Count-and-Aggregation/m-p/651022#M1065886</guid>
      <dc:creator />
      <dc:date>2014-09-20T08:33:12Z</dc:date>
    </item>
  </channel>
</rss>

