<?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 Strange aggregation results... in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498190#M186183</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a fact table in my database that captures school enrollment data. The table contains the following columns: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13873073678379101" jivemacro_uid="_13873073678379101" modifiedtitle="true"&gt;
&lt;P&gt;id, school_grade_id, gender_id, ethnicity_id, number_enrolled, and enrollment_year&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I sum the number enrolled for a particular school and year, I am getting some inconsistent results.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I do a direct SQL query of my database, I get a value of 446 students for this particular school in this particular year, however when I make the same query in Qlikview using the expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13873074223539621" jivemacro_uid="_13873074223539621"&gt;
&lt;P&gt;sum({Sample1&amp;lt;enrollment_year={2013}&amp;gt;}number_enrolled)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I ensure that I have the correct school selected in the Sample1 state, I get 457.&amp;nbsp; Investigation has narrowed it down to three particular records that show up in Qlikview as being associations, that are not present in my database.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After checking problem ID's to my database, those records that are causing the problem are in my database with a completely separate school_grade_id's, and should not be getting associated with the school I currently have selected. I cannot come up with a reason for why this would be happening.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some more background: I have quite a large data model for this dashboard, so in an effort to resolve this on my own, I started a new document and loaded in only the essential tables to run my aggregation.&amp;nbsp; In the new dashboard, Qlikview returns the correct result. This leads me to believe there is an issue with my data model. However, the results are correct for all of the other schools I have spot checked thus far, and I cannot isolate any unique attribute of this problem school that would cause this to happen. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the screen shots below. Any insight would be appreciated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/50574_Capture.JPG.jpg" style="width: 620px; height: 292px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/50579_Capture.JPG.jpg" style="width: 620px; height: 269px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Dec 2013 19:30:50 GMT</pubDate>
    <dc:creator>bdiamante</dc:creator>
    <dc:date>2013-12-17T19:30:50Z</dc:date>
    <item>
      <title>Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498190#M186183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a fact table in my database that captures school enrollment data. The table contains the following columns: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13873073678379101" jivemacro_uid="_13873073678379101" modifiedtitle="true"&gt;
&lt;P&gt;id, school_grade_id, gender_id, ethnicity_id, number_enrolled, and enrollment_year&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I sum the number enrolled for a particular school and year, I am getting some inconsistent results.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I do a direct SQL query of my database, I get a value of 446 students for this particular school in this particular year, however when I make the same query in Qlikview using the expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13873074223539621" jivemacro_uid="_13873074223539621"&gt;
&lt;P&gt;sum({Sample1&amp;lt;enrollment_year={2013}&amp;gt;}number_enrolled)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I ensure that I have the correct school selected in the Sample1 state, I get 457.&amp;nbsp; Investigation has narrowed it down to three particular records that show up in Qlikview as being associations, that are not present in my database.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After checking problem ID's to my database, those records that are causing the problem are in my database with a completely separate school_grade_id's, and should not be getting associated with the school I currently have selected. I cannot come up with a reason for why this would be happening.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some more background: I have quite a large data model for this dashboard, so in an effort to resolve this on my own, I started a new document and loaded in only the essential tables to run my aggregation.&amp;nbsp; In the new dashboard, Qlikview returns the correct result. This leads me to believe there is an issue with my data model. However, the results are correct for all of the other schools I have spot checked thus far, and I cannot isolate any unique attribute of this problem school that would cause this to happen. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the screen shots below. Any insight would be appreciated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/50574_Capture.JPG.jpg" style="width: 620px; height: 292px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/50579_Capture.JPG.jpg" style="width: 620px; height: 269px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 19:30:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498190#M186183</guid>
      <dc:creator>bdiamante</dc:creator>
      <dc:date>2013-12-17T19:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498191#M186184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;It's not necessarily the school that's the problem. It could be a table linked to one of the other id fields. If you have a school with incorrect totals you could select that school and then reduce the data: File -&amp;gt; Reduce Data -&amp;gt; Keep Possible Values. That may make it easier to spot the problem table(s).&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 20:19:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498191#M186184</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-12-17T20:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498192#M186185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you know why school grade ID is different in your model compared to database?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 20:57:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498192#M186185</guid>
      <dc:creator />
      <dc:date>2013-12-17T20:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498193#M186186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is essentially the problem I'm trying to describe.&amp;nbsp; That shouldn't be the case, ever.&amp;nbsp; The same enrollment_fact_id shows two different school_grade_ids in Qlikview and my database... how can this happen?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 21:10:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498193#M186186</guid>
      <dc:creator>bdiamante</dc:creator>
      <dc:date>2013-12-17T21:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498194#M186187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have any joins in your load? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 21:14:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498194#M186187</guid>
      <dc:creator />
      <dc:date>2013-12-17T21:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498195#M186188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I create a Link Table to keep the three fact tables I have from associating common dimensions with each other, so I do have some concatenated tables. My script doesn't have any explicit joins though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 21:20:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498195#M186188</guid>
      <dc:creator>bdiamante</dc:creator>
      <dc:date>2013-12-17T21:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498196#M186189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you are saying you have concatenate loads, Can you add a field which carries name of the table, So that you can see from where these records are coming.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 21:58:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498196#M186189</guid>
      <dc:creator />
      <dc:date>2013-12-17T21:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498197#M186190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So the issue here was both simple and dangerous.&amp;nbsp; I had used several concatenated keys while creating my link table. When creating these keys, I used this method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_13874721133747696 jive_text_macro jive_macro_code" jivemacro_uid="_13874721133747696"&gt;
&lt;P&gt;key = school_id &amp;amp; grade_id &amp;amp; subject_id &amp;amp; ...&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's say the values in those various fields I was concatenating were as follows: RECORD1: school_id=1101, grade_id=5, subject_id=2, RECORD2: school_id=110, grade_id=15, subject_id=2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When concatenated, these two records which shouldn't associate with each other, do associate because their concatenated keys become (mistakenly) the same.&amp;nbsp; The solution was simply to add a delimiter between each field I concatenated.&amp;nbsp; This is easy to overlook when creating your keys but can have huge impacts on your results! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Dec 2013 16:44:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498197#M186190</guid>
      <dc:creator>bdiamante</dc:creator>
      <dc:date>2013-12-19T16:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Strange aggregation results...</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498198#M186191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice eh? That's one reason why using the autonumber is a good idea. The other is that fields with autonumber values take up less memory. From &lt;A _jive_internal="true" class="font-color-normal" href="https://community.qlik.com/blogs/qlikviewdesignblog/2012/11/20/symbol-tables-and-bit-stuffed-pointers" style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #3d3d3d;"&gt;Symbol Tables and Bit-Stuffed Pointers&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;When creating QlikView scripts, always ask yourself if there is any way to reduce these numbers, to minimize the memory usage. Here are a couple of common cases:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You have a long, concatenated, composite key that you don’t need to display. &lt;STRONG&gt;Use Autonumber() and the symbols will take no space in the symbol table&lt;/STRONG&gt;. The integer values will instead be calculated implicitly.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Dec 2013 16:57:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-aggregation-results/m-p/498198#M186191</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-12-19T16:57:56Z</dc:date>
    </item>
  </channel>
</rss>

