<?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: Additional Decimals in SUM in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469104#M1149865</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the following test, and you will better see what happens:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create and run a script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Load Round(Rand(),0.01) as x autogenerate 20 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will create 20 rows, each with a number with two decimals.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Create a text box with the following expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =Num(Sum(x),'0.000000000000000')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you can see if the sum contains rounding "errors". It does so roughly every 2nd run. But if you use more than 20 rows, it will occur more often.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Create a pivot table with x as dimension and the following expression&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num(x,'(BIN) 0.000000000000000000000000000000000000000000000000000000000000')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you will see the binary representation of the numbers. You will see that these numbers are not always exact - they often have recurring sequence of numbers that are cut off in position 53. Hence, they are in fact truncated at this position.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Jun 2013 08:44:16 GMT</pubDate>
    <dc:creator>hic</dc:creator>
    <dc:date>2013-06-13T08:44:16Z</dc:date>
    <item>
      <title>Additional Decimals in SUM</title>
      <link>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469101#M1149862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found something weird that I can't figure out. Please see the attached picture.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a field which shows account balances. When I sum all the balances (about half a million records) I noticed that when formatted as a number, it shows more than 2 decimals. It comes to &lt;SPAN style="color: black; font-size: 8.0pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;STRONG&gt;694,082,201.58004&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Tahoma','sans-serif'; color: black;"&gt;There should be no records with more than 2 decimals, so I tried to track down such records. I make multiple selections while keeping an eye on the sum, and got it down to about 40,000. When I make further selections the decimals are normal (2).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Tahoma','sans-serif'; color: black;"&gt;In the table box in the picture you can see the accounts remaining and their balances - when I send this table to excel and I autosum, it also gives me 75300995.820001 - but when I look at all the records individually none of them have more then 2 decimals!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Tahoma','sans-serif'; color: black;"&gt;When in Qlikview's table box (see picture), I select all of the accounts except for the very top account (10201102080000178583) then the sum changes to a total with only 2 decimals, which tells me this account is the one with the multiple decimals, but when I select it the balance is 2361.35 with only 2 decimals.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Tahoma','sans-serif'; color: black;"&gt;What the hell - am I crazy? where does the 00004 come from?&lt;/SPAN&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;SPAN style="font-size: 8.0pt; font-family: 'Tahoma','sans-serif'; color: black;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Tahoma','sans-serif'; color: black;"&gt;Gerhard&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 07:49:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469101#M1149862</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2013-06-13T07:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Additional Decimals in SUM</title>
      <link>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469102#M1149863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is normal behaviour for software that use 64-bit binary representation of numbers. Your numbers simply cannot be represented exactly by a binary number, so when you add a lot of numbers, each with a very small rounding "error", you will get this effect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Work around 1:&lt;/P&gt;&lt;P&gt;use a rounding function: Round(Sum(Amount),0.01)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Work around 2:&lt;/P&gt;&lt;P&gt;Always use integers! If you know that all amounts are exact in cents (two decimals on the dollar) then you can convert everything to cents before you sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See more on&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;A class="jive-link-external-small" href="http://support.microsoft.com/kb/42980" style="color: #007fc0;"&gt;Microsoft knowledge base&lt;/A&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;A class="jive-link-external-small" href="http://csharpindepth.com/Articles/General/FloatingPoint.aspx" style="color: #007fc0;"&gt;Binary floating point and .NET&lt;/A&gt;&lt;/P&gt;&lt;P&gt;these articles are about .Net, but most of it is applicable also in QlikView arithmentics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 07:58:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469102#M1149863</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2013-06-13T07:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Additional Decimals in SUM</title>
      <link>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469103#M1149864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Henric,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still don't get where the "small rounding error" on the individual numbers come from, since I pull this data from a text file which is already rounded to cents (2 decimals only) - but I'll read up a bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;G&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 08:15:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469103#M1149864</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2013-06-13T08:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Additional Decimals in SUM</title>
      <link>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469104#M1149865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the following test, and you will better see what happens:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create and run a script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Load Round(Rand(),0.01) as x autogenerate 20 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will create 20 rows, each with a number with two decimals.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Create a text box with the following expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =Num(Sum(x),'0.000000000000000')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you can see if the sum contains rounding "errors". It does so roughly every 2nd run. But if you use more than 20 rows, it will occur more often.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Create a pivot table with x as dimension and the following expression&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Num(x,'(BIN) 0.000000000000000000000000000000000000000000000000000000000000')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you will see the binary representation of the numbers. You will see that these numbers are not always exact - they often have recurring sequence of numbers that are cut off in position 53. Hence, they are in fact truncated at this position.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 08:44:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Additional-Decimals-in-SUM/m-p/469104#M1149865</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2013-06-13T08:44:16Z</dc:date>
    </item>
  </channel>
</rss>

