<?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: Count Distinct Based on Sum in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332481#M515940</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this attached. You cannot use a calculatedDimension in your aggr() expression to get the count. So created a Calculated dimension in the script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change your Excel file path if you want to reload the script again. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Apr 2017 21:54:43 GMT</pubDate>
    <dc:creator>vishsaggi</dc:creator>
    <dc:date>2017-04-03T21:54:43Z</dc:date>
    <item>
      <title>Count Distinct Based on Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332480#M515939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm fairly new to Qlikview and need some help with a pivot table. I have a dataset that includes Clients; each client can have multiple Segments of business, and each Segment can have multiple Benefits. I have Expenses by fiscal year for each available Benefit. It looks something like this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/158762_pastedImage_0.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;P&gt;I need to show a summary of a subset of clients/expenses based on the Segment and Benefit so I've created a calculated dimension:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;IF&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Segment&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='A' &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Segment&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='C') &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;AND&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Benefit&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;=96 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Benefit&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;=97 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Benefit&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;=98),&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Client&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I'd like to see the sum of expenses for all years, which is easy enough. Here's where I'm stumped: I need to show the count of years where the sum of expenses for the year is less than 0, without having the year as a dimension. I want my final pivot table to look something like this (but obviously with the correct data in the Count column):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;IMG class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/158763_pastedImage_6.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;f I throw the Year into another pivot, I can use that to eyeball what the results should be, I just don't know how to get it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;IMG class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/158764_pastedImage_7.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Expected Counts:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Client 1 - 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Client 2 - 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Client 3 - 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Client 4 - 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Client 5 - 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Any help would be greatly appreciated. I've attached a QVW file if that helps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Apr 2017 20:22:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332480#M515939</guid>
      <dc:creator />
      <dc:date>2017-04-03T20:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct Based on Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332481#M515940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this attached. You cannot use a calculatedDimension in your aggr() expression to get the count. So created a Calculated dimension in the script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change your Excel file path if you want to reload the script again. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:54:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332481#M515940</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-04-03T21:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct Based on Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332482#M515941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;SUM&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;If&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Expense&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;), &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Client&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Year&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))&amp;lt;0,1)) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Apr 2017 22:01:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332482#M515941</guid>
      <dc:creator>craigsutton</dc:creator>
      <dc:date>2017-04-03T22:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct Based on Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332483#M515942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another way to avoid the if statement and use set analysis instead of using calculated dimension&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=-Sum(Aggr(RangeMin(Sign(Sum({&amp;lt;Segment = {'A'}, Benefit = {96, 97, 98}&amp;gt;+&amp;lt;Segment = {'C'}, Benefit = {96, 97, 98}&amp;gt;}Expense)), 0), Client, Year))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 08:31:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332483#M515942</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-04-04T08:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct Based on Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332484#M515943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That works perfectly. Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 18:02:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332484#M515943</guid>
      <dc:creator />
      <dc:date>2017-04-04T18:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Count Distinct Based on Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332485#M515944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Craig. Unfortunately I think your formula is picking up some of the Segments and Benefits that are supposed to be excluded so I don't get the correct result in every case:&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/158914_pastedImage_0.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;P&gt;The answer from @stalwar1 works well by using a set analysis (although I'd prefer to avoid that if at all possible).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 18:07:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-Based-on-Sum/m-p/1332485#M515944</guid>
      <dc:creator />
      <dc:date>2017-04-04T18:07:02Z</dc:date>
    </item>
  </channel>
</rss>

