<?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 Total count is not equal to sum of rows in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Total-count-is-not-equal-to-sum-of-rows/m-p/480509#M1130823</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am completely stuck, and could really use some help.&amp;nbsp; My business case is that I need to create a Straight Table chart that counts the total number of distinct patients by practice that have had charge transactions over a rolling 12 months.&amp;nbsp; This needs to be calculated for a specific region, and it seems simple enough, but there is a catch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The catch is that a patient could have charges at multiple practices within the region, but they should only count once based on their assigned "home" location.&amp;nbsp; Before selecting any dimensions in my table, I created the following formula to determine that my total count should be 166,899:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count({$&amp;lt;Region={'North'}, Year=, MonthName=, [Month Counter]={'&amp;gt;=$(=min([Month Counter]))&amp;lt;$(=min([Month Counter])+12)'}, Patient_Transactions.category_id={*}-{28,29,30}, Patient_Transactions.trans_code={'&amp;gt;=100'}&amp;gt;} DISTINCT Patients.unique_id)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This formula works, and I have been able to verify that the total is accurate.&amp;nbsp; Now, when I add my "Practice" dimension to the chart, I am able to get count totals by Practice, but the sum of my rows now equals 169,037.&amp;nbsp; This tells me that this chart is totaling the distinct count by Practice, and not overall.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, I am working with 3 source tables: Patients, Locations and Patient_Transactions.&amp;nbsp; My patients' home location is stored in a field titled "Patients.location_id" in the Patients table, but this field only contains a numeric value, and I need to display the Practice name from the Locations table.&amp;nbsp; When I add AGGR( . . . , Patients.location_id) to the formula above, I get a table that only displays a couple of Practices, and a total of 51,953.&amp;nbsp; Based on my limited knowledge, I can only assume that this result is due to my one to many and many to one relationships that are stored in the script.&amp;nbsp; Any other variations that I've tried with AGGR, such as AGGR with Patients.unique_id, AGGR with Practice, AGGR with Patients.location_id, Practice either return values of zero, one or 169,037.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am obviously missing something here, and unfortunately I am not able to upload an example due to the sensitivity of the patient information contained in my application.&amp;nbsp; With what I've written above, can you see anything that I might be missing?&amp;nbsp; Please feel free to let me know if you need more information about my setup.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Nov 2013 17:29:00 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-11-22T17:29:00Z</dc:date>
    <item>
      <title>Total count is not equal to sum of rows</title>
      <link>https://community.qlik.com/t5/QlikView/Total-count-is-not-equal-to-sum-of-rows/m-p/480509#M1130823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am completely stuck, and could really use some help.&amp;nbsp; My business case is that I need to create a Straight Table chart that counts the total number of distinct patients by practice that have had charge transactions over a rolling 12 months.&amp;nbsp; This needs to be calculated for a specific region, and it seems simple enough, but there is a catch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The catch is that a patient could have charges at multiple practices within the region, but they should only count once based on their assigned "home" location.&amp;nbsp; Before selecting any dimensions in my table, I created the following formula to determine that my total count should be 166,899:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count({$&amp;lt;Region={'North'}, Year=, MonthName=, [Month Counter]={'&amp;gt;=$(=min([Month Counter]))&amp;lt;$(=min([Month Counter])+12)'}, Patient_Transactions.category_id={*}-{28,29,30}, Patient_Transactions.trans_code={'&amp;gt;=100'}&amp;gt;} DISTINCT Patients.unique_id)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This formula works, and I have been able to verify that the total is accurate.&amp;nbsp; Now, when I add my "Practice" dimension to the chart, I am able to get count totals by Practice, but the sum of my rows now equals 169,037.&amp;nbsp; This tells me that this chart is totaling the distinct count by Practice, and not overall.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, I am working with 3 source tables: Patients, Locations and Patient_Transactions.&amp;nbsp; My patients' home location is stored in a field titled "Patients.location_id" in the Patients table, but this field only contains a numeric value, and I need to display the Practice name from the Locations table.&amp;nbsp; When I add AGGR( . . . , Patients.location_id) to the formula above, I get a table that only displays a couple of Practices, and a total of 51,953.&amp;nbsp; Based on my limited knowledge, I can only assume that this result is due to my one to many and many to one relationships that are stored in the script.&amp;nbsp; Any other variations that I've tried with AGGR, such as AGGR with Patients.unique_id, AGGR with Practice, AGGR with Patients.location_id, Practice either return values of zero, one or 169,037.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am obviously missing something here, and unfortunately I am not able to upload an example due to the sensitivity of the patient information contained in my application.&amp;nbsp; With what I've written above, can you see anything that I might be missing?&amp;nbsp; Please feel free to let me know if you need more information about my setup.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 17:29:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Total-count-is-not-equal-to-sum-of-rows/m-p/480509#M1130823</guid>
      <dc:creator />
      <dc:date>2013-11-22T17:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Total count is not equal to sum of rows</title>
      <link>https://community.qlik.com/t5/QlikView/Total-count-is-not-equal-to-sum-of-rows/m-p/480510#M1130824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Jason&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is a long question to read &amp;amp; fathom out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you be able to somehow distill your question down the to core of the issue and share a sample qvw with some sample data loaded ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your patient related data sounds like it would be unwise to share it on a public forum as is.&amp;nbsp; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;This document &lt;/SPAN&gt;&lt;A _jive_internal="true" data-containerid="2049" data-containertype="14" data-objectid="1290" data-objecttype="102" href="https://community.qlik.com/docs/DOC-1290" style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3778c7;"&gt;Preparing examples for Upload - Reduction and Data Scrambling &lt;/A&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;by &lt;/SPAN&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-link-profile-small" data-containerid="-1" data-containertype="-1" data-objectid="2286" data-objecttype="3" href="https://community.qlik.com/people/robwunderlich" style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3778c7;"&gt;Rob Wunderlich&lt;/A&gt;&amp;nbsp;&amp;nbsp; may &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;help you make it suitable for sharing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;Bill&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Nov 2013 18:47:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Total-count-is-not-equal-to-sum-of-rows/m-p/480510#M1130824</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-23T18:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Total count is not equal to sum of rows</title>
      <link>https://community.qlik.com/t5/QlikView/Total-count-is-not-equal-to-sum-of-rows/m-p/480511#M1130825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would recommend you approach this by flagging each patient if they had a valid transaction.&amp;nbsp; I will call it "VisitWithin12MonthsFlag".&amp;nbsp; So all the patients will get flagged with transactions in the last 12 months.&amp;nbsp; For each patient you should also have a field for Home Practice.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can then setup a table with Home Practice as the dimension and Count(Distinct {$&amp;lt;VisitWithin12MonthsFlag = {1}&amp;gt;} PatientID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will count all the unique PateintIDs who have had a transaction at ANY practice and summarize them by Home Practice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 21:29:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Total-count-is-not-equal-to-sum-of-rows/m-p/480511#M1130825</guid>
      <dc:creator>Josh_Good</dc:creator>
      <dc:date>2013-11-25T21:29:40Z</dc:date>
    </item>
  </channel>
</rss>

