<?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: Wrong data when using sum() in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116301#M750751</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can create a new key by concatenating or using Hash functions to create a combined key out of the 4 field. This will then help you remove your synthetic key.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Nov 2018 16:48:25 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-11-07T16:48:25Z</dc:date>
    <item>
      <title>Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116292#M750740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table containing a &lt;STRONG&gt;STOCK &lt;/STRONG&gt;field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added a text object to debug my application:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&lt;STRONG&gt;Only&lt;/STRONG&gt;({&amp;lt;TRANSACTION_DATE = {'$(vStartDate)'}&amp;gt;} If('$(vStartDate)' &amp;lt;= '$(vEndDate)', &lt;STRONG&gt;STOCK&lt;/STRONG&gt;, 0))&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; Gives me the correct value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&lt;STRONG&gt;Sum&lt;/STRONG&gt;({&amp;lt;TRANSACTION_DATE = {'$(vStartDate)'}&amp;gt;} If('$(vStartDate)' &amp;lt;= '$(vEndDate)', STOCK_CONS, 0))&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;nbsp; Gives a wrong value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could please explain to me the difference between the 2 expressions above.&lt;/P&gt;&lt;P&gt;and what is the meaning of the function &lt;STRONG&gt;Only?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Abdallah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116292#M750740</guid>
      <dc:creator>absekrafi</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116293#M750741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the difference between STOCK and STOCK_CONS field? I mean a sum on 1 field will give a different result from Sum on another field (not even bringing Sum vs Only into discussion here)...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:56:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116293#M750741</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-07T14:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116294#M750742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a mistyping only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;=&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;Only&lt;/STRONG&gt;({&amp;lt;TRANSACTION_DATE = {'$(vStartDate)'}&amp;gt;} If('$(vStartDate)' &amp;lt;= '$(vEndDate)', &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;STOCK&lt;/STRONG&gt;, 0))&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;gt;&amp;gt; Gives me the correct value. &lt;STRONG&gt;85 798.593&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;=&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;Sum&lt;/STRONG&gt;({&amp;lt;TRANSACTION_DATE = {'$(vStartDate)'}&amp;gt;} If('$(vStartDate)' &amp;lt;= '$(vEndDate)', &lt;STRONG&gt;STOCK&lt;/STRONG&gt;, 0))&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;gt;&amp;gt;&amp;nbsp; Gives a wrong value. &lt;STRONG&gt;343 194.372&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;The value is unique, in the source table, for the example I took (sulfur). So the Sum() function is somehow adding or multiplying the data (from the table).&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;But, after reading in the qlikview help online, Only() is not a solution to what I want because there are cases where a Sum(): (adding values) is needed.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;Can it, also, due to the &lt;SPAN style="text-decoration: underline;"&gt;date&lt;/SPAN&gt; format?&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Thank you&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 15:19:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116294#M750742</guid>
      <dc:creator>absekrafi</dc:creator>
      <dc:date>2018-11-07T15:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116295#M750743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You seem to have 4 rows of data with the same value... which is why you are seeing 343,194,372 when you use Sum... If you do Sum(DISTINCT... you will get to your 85,798,593 number...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=Sum(DISTINCT {&amp;lt;TRANSACTION_DATE = {'$(vStartDate)'}&amp;gt;} If('$(vStartDate)' &amp;lt;= '$(vEndDate)', STOCK, 0))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't recommend using Sum(DISTINCT as it will DISTINCT in cases where you have a same value which you do want to Sum... but in this case Only and Sum(DISTINCT will give the same value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only works because all 4 rows have the same exact value... which is 85,798,593... if a single value was different... for example one row was 5 instead of 85,798,593... you will see 0 using Only function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 15:32:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116295#M750743</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-07T15:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116296#M750744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abdallah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;343194.372 is exactly 4 times 85798.593, so I think your Sum is adding this number up 4 times (somehow), your Only is returning the lone value as the 4 values under consideration are all the same (if they were not would return null). Are you absolutely sure the value &lt;SPAN style="color: #575757; font-family: arial,helvetica,sans-serif; font-size: 13.33px; font-style: normal; font-weight: 400; text-align: left; text-indent: 0px;"&gt;85798.593 &lt;/SPAN&gt;is unique in your source tables and what happens if you add the &lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;TRANSACTION_DATE to a straight table with the 2 expressions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 15:38:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116296#M750744</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2018-11-07T15:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116297#M750745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sunny,&lt;/P&gt;&lt;P&gt;Adding distinct fixed the problem. I just have one question, to what DISTINCT apply here: to the dates (TRANSACTION_DATE&lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f2f2f2;"&gt; , &lt;/STRONG&gt;vStartDate and vEndDate&lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f2f2f2;"&gt;) &lt;/STRONG&gt;or to the field STOCK only.&lt;/P&gt;&lt;P&gt;As you mentionned, the problem where we have the same value repeated and we want to add them still has no solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;I enclosed both data from the oracle data base "sum() issue.csv" and the straight table as detailed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing came to my head is when I do a JOIN between the table to get the FACT table, may be I did that more than once with the table containing my data. But, I think I checked that and it's ok. I will checked that again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much,&lt;/P&gt;&lt;P&gt;Abdallah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 16:02:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116297#M750745</guid>
      <dc:creator>absekrafi</dc:creator>
      <dc:date>2018-11-07T16:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116298#M750746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DISTINCT is applied to your dimension. So, across all the rows against the dimension... it will pick each of the distinct value&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 16:14:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116298#M750746</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-07T16:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116299#M750747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Join is def. the problem. I suggest to keep the aggregated data in a separate table linked with your FACT Table on a key field to avoid duplication.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 16:15:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116299#M750747</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-07T16:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116300#M750749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sunny,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I removed my "&lt;STRONG&gt;consumption&lt;/STRONG&gt;" table from the &lt;STRONG&gt;fact&lt;/STRONG&gt; table &lt;STRONG&gt;and at a first sight my data are ok using sum() without DISTINCT.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I still have a &lt;STRONG&gt;synthetic&lt;/STRONG&gt; &lt;STRONG&gt;key&lt;/STRONG&gt; (because I have 4 common fields: columns between the two tables.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much Sunny and Chris for your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note :I will clean my discussion when my connection to the server is better and change theme to resolved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Abdallah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 16:36:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116300#M750749</guid>
      <dc:creator>absekrafi</dc:creator>
      <dc:date>2018-11-07T16:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116301#M750751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can create a new key by concatenating or using Hash functions to create a combined key out of the 4 field. This will then help you remove your synthetic key.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 16:48:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116301#M750751</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-11-07T16:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116302#M750753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What if the results are good in a straight table and not in a pivot table with the same formula?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Abdallah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2018 11:11:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116302#M750753</guid>
      <dc:creator>absekrafi</dc:creator>
      <dc:date>2018-11-08T11:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116303#M750756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abdallah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would be a bit surprised, If you add fast change option (on general tab) &amp;amp; switch between the two types (pivot &amp;amp; straight tables) does that show any discrepancy?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2018 11:22:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/116303#M750756</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2018-11-08T11:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong data when using sum()</title>
      <link>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/1505817#M750758</link>
      <description>&lt;P&gt;Hi Sunny,&lt;/P&gt;&lt;P&gt;I added a new field to each table when I use JOIN. it is "recno()". This adds a record number to every entry of each table when doing a JOIN so that the rows will be different.&lt;/P&gt;&lt;P&gt;The problem is fixed.&lt;/P&gt;&lt;P&gt;Note: I like the new community site!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Abdallah&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 07:45:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Wrong-data-when-using-sum/m-p/1505817#M750758</guid>
      <dc:creator>absekrafi</dc:creator>
      <dc:date>2018-11-14T07:45:57Z</dc:date>
    </item>
  </channel>
</rss>

