<?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: Sum return incorrect result due to duplicates hidden in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626014#M595653</link>
    <description>&lt;P&gt;Why do you join the aggregated table back to the original table?&lt;/P&gt;&lt;P&gt;Imagine if you have a table of 10 rows with a unique key, then perform a group by.&lt;/P&gt;&lt;P&gt;Result will return one row for that table.&lt;/P&gt;&lt;P&gt;Next, you join back to the original table with the same key, which will lead to one-to-many join.&lt;/P&gt;&lt;P&gt;Try to not join back to original table, use a key to link between the aggregated table and the original table.&lt;/P&gt;&lt;P&gt;In this case, you do not need to create composite key as you have only one key field in your table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Insert a comment your join statement will do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Arthur Fong&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2019 23:56:59 GMT</pubDate>
    <dc:creator>Arthur_Fong</dc:creator>
    <dc:date>2019-09-19T23:56:59Z</dc:date>
    <item>
      <title>Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1625782#M595651</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I try to calculate the amount of the sales, the&amp;nbsp; quantity of the current stock, the amount received and the amount consumed.&lt;/P&gt;&lt;P&gt;But, the result returned by Group By is not correct at all !&lt;/P&gt;&lt;P&gt;After some research, in this forum, I find a &lt;A href="https://community.qlik.com/t5/New-to-QlikView/SUM-calculates-incorrect-values/td-p/770699" target="_self"&gt;topic&lt;/A&gt; when a "&lt;EM&gt;Qlikviewer"&lt;/EM&gt;&amp;nbsp; advise to use a count on the key.&lt;/P&gt;&lt;P&gt;Normally, the result of the count(key) must be equal to one. But, in my case, the result is 8.&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;How can I avoid this problem in order to return the correct result.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Below the logic behind my script:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;JOIN&lt;/STRONG&gt;(REF_TAB)&lt;/P&gt;&lt;P&gt;TAB_CALCUL:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD DISTINCT&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Key_ID,&lt;/P&gt;&lt;P&gt;ROUND(SUM(Sales),0.01) AS TotSales,&lt;BR /&gt;ROUND(SUM(Receipt)-SUM(Consumption),0.01) AS Stock,&lt;BR /&gt;ROUND(SUM(Receipt) ,0.01) AS AmountReceipt,&lt;BR /&gt;ROUND(SUM(Consumption),0.01) AS AmountConsump&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RESIDENT&lt;/STRONG&gt; REF_TAB&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GROUP BY&lt;/STRONG&gt;&amp;nbsp;KeyID;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 02:26:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1625782#M595651</guid>
      <dc:creator>Black_Hole</dc:creator>
      <dc:date>2024-11-16T02:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626008#M595652</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Any help to lead me toward the resolution of this problem.&lt;/P&gt;&lt;P&gt;Please tell me if my request is not clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 22:10:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626008#M595652</guid>
      <dc:creator>Black_Hole</dc:creator>
      <dc:date>2019-09-19T22:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626014#M595653</link>
      <description>&lt;P&gt;Why do you join the aggregated table back to the original table?&lt;/P&gt;&lt;P&gt;Imagine if you have a table of 10 rows with a unique key, then perform a group by.&lt;/P&gt;&lt;P&gt;Result will return one row for that table.&lt;/P&gt;&lt;P&gt;Next, you join back to the original table with the same key, which will lead to one-to-many join.&lt;/P&gt;&lt;P&gt;Try to not join back to original table, use a key to link between the aggregated table and the original table.&lt;/P&gt;&lt;P&gt;In this case, you do not need to create composite key as you have only one key field in your table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Insert a comment your join statement will do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Arthur Fong&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 23:56:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626014#M595653</guid>
      <dc:creator>Arthur_Fong</dc:creator>
      <dc:date>2019-09-19T23:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626180#M595654</link>
      <description>&lt;P&gt;Hello Arthur (&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6678"&gt;@Arthur_Fong&lt;/a&gt;),&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;I need to join to the original because the variable calculated is used in another resident table.&lt;/P&gt;&lt;P&gt;If I don't join the variable is not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please could you advise what I can in this case to resolve this problem of duplicates.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 09:27:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626180#M595654</guid>
      <dc:creator>Black_Hole</dc:creator>
      <dc:date>2019-09-20T09:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626189#M595655</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;the problem is the join, because the original table has multiple rows with the same id, so the result of group by was repeated for each row, with this logic.&lt;/P&gt;&lt;P&gt;Maybe you could do something like this if you use this value in a table, to avoid duplicated:&lt;/P&gt;&lt;P&gt;example&lt;/P&gt;&lt;P&gt;Sum(Aggr(Max(&lt;SPAN&gt;TotSales),&amp;nbsp;KeyID))&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 09:41:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626189#M595655</guid>
      <dc:creator>StarinieriG</dc:creator>
      <dc:date>2019-09-20T09:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626194#M595656</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/83275"&gt;@StarinieriG&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I will try your solution.&lt;/P&gt;&lt;P&gt;Just to be sure, the expression&amp;nbsp;&lt;SPAN&gt;Sum(Aggr(Max(&lt;/SPAN&gt;&lt;SPAN&gt;TotSales),&amp;nbsp;KeyID))&lt;/SPAN&gt; &amp;nbsp;can be implemented in a load statement ?&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 09:47:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626194#M595656</guid>
      <dc:creator>Black_Hole</dc:creator>
      <dc:date>2019-09-20T09:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626197#M595657</link>
      <description>&lt;P&gt;No, because if you want to avoid duplicate rows in load statement you couldn't use the join&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 09:50:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626197#M595657</guid>
      <dc:creator>StarinieriG</dc:creator>
      <dc:date>2019-09-20T09:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sum return incorrect result due to duplicates hidden</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626231#M595658</link>
      <description>&lt;P&gt;Re&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/83275"&gt;@StarinieriG&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I understand. So, I try your solution in an expression and the result is correct.&lt;/P&gt;&lt;P&gt;Many thanks for your great help!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 10:40:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-return-incorrect-result-due-to-duplicates-hidden/m-p/1626231#M595658</guid>
      <dc:creator>Black_Hole</dc:creator>
      <dc:date>2019-09-20T10:40:34Z</dc:date>
    </item>
  </channel>
</rss>

