<?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 SUM Distinct in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221261#M74083</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How would you write the following SQL statement as a QV expression. My fact table is MONTH_PTNT_CNT which has data at regimen level(a lowest regimen level = RGMN_NBR). Another table is REGIMEN_GRP table which states what regimen belongs to which group. It is highly likely that a regimen can belong to more than one regimen_group Or you can say that some regimen_nbr will share parents. In SQL you can easily identify by using IN keyword as stated in the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;sum(TOT_PTNT_CNT) &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;from MONTH_PTNT_CNT &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;where s_gid=21 &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;and rgmn_nbr IN (select rgmn_nbr from REGIMEN_GRP where s_gid=21 and rgmn_grp_gid = 15) &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;and MTH_INT=200907 &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;and dg_combo_nbr=1 &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Jul 2010 00:57:59 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-07-14T00:57:59Z</dc:date>
    <item>
      <title>SUM Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221257#M74079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a fact table containing patient data. For example, patient is treated for Disease A , Disease B or combination AB. A patient might have multiple entries in a fact table among different Disease group. Now, when I sum on patient for an individual group I get the total from all three groups. How can I tell QV to do a distinct on a patient. If patient has already included in a count for one group DONT count it another time.&lt;/P&gt;&lt;P&gt;Please let me know if you need additional info.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jul 2010 22:59:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221257#M74079</guid>
      <dc:creator />
      <dc:date>2010-07-12T22:59:33Z</dc:date>
    </item>
    <item>
      <title>SUM Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221258#M74080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure I understand the question.&lt;/P&gt;&lt;P&gt;If you don't have disease as a dimension in your chart, count(distinct patient) will only count the patients once. If you DO have disease as a dimension in your chart, WHICH disease did you want to include the patient under if they're been treated for multiple diseases? QlikView isn't making the decision for you, which is why you'll see the patient counted under each disease. However, if you do a total for the diseases, it will then count correctly again (unless you select sum of rows).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jul 2010 23:46:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221258#M74080</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-12T23:46:28Z</dc:date>
    </item>
    <item>
      <title>SUM Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221259#M74081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use set expressions to achieve this:&lt;/P&gt;&lt;P&gt;count({&amp;lt;disease={'A'}&amp;gt;} patient)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jul 2010 23:51:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221259#M74081</guid>
      <dc:creator />
      <dc:date>2010-07-12T23:51:49Z</dc:date>
    </item>
    <item>
      <title>SUM Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221260#M74082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;John You understood the question right. I have disease as a dimesion in my table chart. I have given a group_code for a patient and disease where patient belongs to. If patient has code A for a particular date, and he occurs under code B on the same date I want to exclude one. I know its hard for you to understand. I will share the app soon.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jul 2010 00:56:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221260#M74082</guid>
      <dc:creator />
      <dc:date>2010-07-13T00:56:27Z</dc:date>
    </item>
    <item>
      <title>SUM Distinct</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221261#M74083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How would you write the following SQL statement as a QV expression. My fact table is MONTH_PTNT_CNT which has data at regimen level(a lowest regimen level = RGMN_NBR). Another table is REGIMEN_GRP table which states what regimen belongs to which group. It is highly likely that a regimen can belong to more than one regimen_group Or you can say that some regimen_nbr will share parents. In SQL you can easily identify by using IN keyword as stated in the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;sum(TOT_PTNT_CNT) &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;from MONTH_PTNT_CNT &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;where s_gid=21 &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;and rgmn_nbr IN (select rgmn_nbr from REGIMEN_GRP where s_gid=21 and rgmn_grp_gid = 15) &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;and MTH_INT=200907 &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;and dg_combo_nbr=1 &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jul 2010 00:57:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Distinct/m-p/221261#M74083</guid>
      <dc:creator />
      <dc:date>2010-07-14T00:57:59Z</dc:date>
    </item>
  </channel>
</rss>

