<?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 Problem with Pivot Table (count distinct and total sum) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-with-Pivot-Table-count-distinct-and-total-sum/m-p/204190#M503222</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As best as I can tell, you are not using aggr() correctly. Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;sum(if(aggr(count(Order),CustomerId)=1,1,0) )&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;What we are doing is counting the number of orders - &lt;B&gt;count(Order)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;for each customerId - &lt;B&gt;aggr(&lt;/B&gt;count(Order)&lt;B&gt;,CustomerId)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;if this equals 1 (or 2, or 3, depending on column), we place 1 in our column, otherwise 0 &lt;B&gt;- if(&lt;/B&gt;aggr(count(Order),CustomerId)&lt;B&gt;=1,1,0)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;Finally, we sum this total - this will not impact our regular lines, since we will just sum up 1 or 0, but in the Total line, this will allow it to count (sum of 1s) the number of customers - &lt;B&gt;sum(&lt;/B&gt;if(aggr(count(Order),CustomerId)=1,1,0) &lt;B&gt;)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this clears things up (the same syntax also works for your second table).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Jun 2010 10:03:28 GMT</pubDate>
    <dc:creator>Or</dc:creator>
    <dc:date>2010-06-28T10:03:28Z</dc:date>
    <item>
      <title>Problem with Pivot Table (count distinct and total sum)</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-Pivot-Table-count-distinct-and-total-sum/m-p/204189#M503221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I would like to have a total on Pivot Table&lt;/P&gt;&lt;P&gt;I tried with dimensionality (without success)&lt;/P&gt;&lt;P&gt;Someone can help me please ?&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;Claudio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 09:46:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-Pivot-Table-count-distinct-and-total-sum/m-p/204189#M503221</guid>
      <dc:creator />
      <dc:date>2010-06-28T09:46:35Z</dc:date>
    </item>
    <item>
      <title>Problem with Pivot Table (count distinct and total sum)</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-Pivot-Table-count-distinct-and-total-sum/m-p/204190#M503222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As best as I can tell, you are not using aggr() correctly. Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;sum(if(aggr(count(Order),CustomerId)=1,1,0) )&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;What we are doing is counting the number of orders - &lt;B&gt;count(Order)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;for each customerId - &lt;B&gt;aggr(&lt;/B&gt;count(Order)&lt;B&gt;,CustomerId)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;if this equals 1 (or 2, or 3, depending on column), we place 1 in our column, otherwise 0 &lt;B&gt;- if(&lt;/B&gt;aggr(count(Order),CustomerId)&lt;B&gt;=1,1,0)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;Finally, we sum this total - this will not impact our regular lines, since we will just sum up 1 or 0, but in the Total line, this will allow it to count (sum of 1s) the number of customers - &lt;B&gt;sum(&lt;/B&gt;if(aggr(count(Order),CustomerId)=1,1,0) &lt;B&gt;)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this clears things up (the same syntax also works for your second table).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 10:03:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-Pivot-Table-count-distinct-and-total-sum/m-p/204190#M503222</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2010-06-28T10:03:28Z</dc:date>
    </item>
    <item>
      <title>Problem with Pivot Table (count distinct and total sum)</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-Pivot-Table-count-distinct-and-total-sum/m-p/204191#M503223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;Now work perfectly !!!&lt;/P&gt;&lt;P&gt;(I used "aggr" few times ! That's the problem)&lt;/P&gt;&lt;P&gt;Claudio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jun 2010 10:55:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-Pivot-Table-count-distinct-and-total-sum/m-p/204191#M503223</guid>
      <dc:creator />
      <dc:date>2010-06-28T10:55:37Z</dc:date>
    </item>
  </channel>
</rss>

