<?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: Elapsed time approximation error? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2131094#M91954</link>
    <description>&lt;P&gt;I assume it's related to the used binary number-system of Qlik which could lead to &lt;A href="https://community.qlik.com/t5/Design/Rounding-Errors/ba-p/1468808#" target="_blank"&gt;Rounding Errors - Qlik Community - 1468808&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Beside the question why you want to create n equally records the above tasks doesn't need an outside-loop else might be just:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;TimeStamps:
    Load Timestamp#('2023-09-01 00:00:00', 'YYYY-MM-DD hh:mm:ss') As EventStart
    	, Timestamp#('2023-09-01 00:00:05', 'YYYY-MM-DD hh:mm:ss') As EventEnd
	AutoGenerate 10000; &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2023 13:57:45 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2023-10-23T13:57:45Z</dc:date>
    <item>
      <title>Elapsed time approximation error?</title>
      <link>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2130978#M91942</link>
      <description>&lt;P&gt;Hi Everyone!&lt;/P&gt;
&lt;P&gt;I'm running into a "weird issue", when I calculated elapsed times between date times / timestamp values seems that I run into an approximation error.&lt;/P&gt;
&lt;P&gt;I've prepared the following sample script to demonstrate what I mean, hoping that some one could indicate what I'm doing wrong here.&lt;/P&gt;
&lt;P&gt;The sample script is supposed to load 10000 records with the same start and end date and time, and then calculate the total elapsed time in seconds among all the records.&lt;/P&gt;
&lt;P&gt;The start is always:&amp;nbsp;2023-09-01 00:00:00, end is always:&amp;nbsp;2023-09-01 00:00:05 (+5 seconds from start)&lt;/P&gt;
&lt;P&gt;The total elapsed time should be 50000 seconds (10000 records * 5 seconds each), instead I get 49999:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="steax_0-1698057493167.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/118711i170AE415D5B65CF8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="steax_0-1698057493167.png" alt="steax_0-1698057493167.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Sample script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Set i = 0;
Do while i &amp;lt; 10000
    TimeStamps:
    Load Timestamp#('2023-09-01 00:00:00', 'YYYY-MM-DD hh:mm:ss') As EventStart
    	, Timestamp#('2023-09-01 00:00:05', 'YYYY-MM-DD hh:mm:ss') As EventEnd
	AutoGenerate 1;    
    i = i + 1;
Loop

Elapsed:
Load Sum(Interval(EventEnd - EventStart, 'ss')) As ElapsedSeconds
Resident TimeStamps;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your time&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 10:42:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2130978#M91942</guid>
      <dc:creator>steax</dc:creator>
      <dc:date>2023-10-23T10:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Elapsed time approximation error?</title>
      <link>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2131094#M91954</link>
      <description>&lt;P&gt;I assume it's related to the used binary number-system of Qlik which could lead to &lt;A href="https://community.qlik.com/t5/Design/Rounding-Errors/ba-p/1468808#" target="_blank"&gt;Rounding Errors - Qlik Community - 1468808&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Beside the question why you want to create n equally records the above tasks doesn't need an outside-loop else might be just:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;TimeStamps:
    Load Timestamp#('2023-09-01 00:00:00', 'YYYY-MM-DD hh:mm:ss') As EventStart
    	, Timestamp#('2023-09-01 00:00:05', 'YYYY-MM-DD hh:mm:ss') As EventEnd
	AutoGenerate 10000; &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 13:57:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2131094#M91954</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2023-10-23T13:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Elapsed time approximation error?</title>
      <link>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2131102#M91955</link>
      <description>&lt;P&gt;As Markus points out, it's a rounding error.&lt;/P&gt;
&lt;P&gt;2023-09-01 00:00:00 = 45170.000000&lt;BR /&gt;2023-09-01 00:00:05 = 45170.000058&lt;/P&gt;
&lt;P&gt;So we are talking about a difference between the two numbers in the 10th significant digit, when the matissa just has 15 digits. Adding 10000 numbers will make the rounding (in the 15th digit) visible.&lt;/P&gt;
&lt;P&gt;If you instead calculate &lt;BR /&gt;Interval(Sum(EventEnd) - Sum(EventStart), 'ss') As ElapsedSeconds&lt;BR /&gt;you will get 50004, which shows how large the rounding error can get.&lt;/P&gt;
&lt;P&gt;See also on &lt;A href="https://community.qlik.com/t5/Design/Rounding-Errors/ba-p/1468808" target="_blank"&gt;https://community.qlik.com/t5/Design/Rounding-Errors/ba-p/1468808&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;HIC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 14:07:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2131102#M91955</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2023-10-23T14:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Elapsed time approximation error?</title>
      <link>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2131455#M91973</link>
      <description>&lt;P&gt;Thanks both, the article was indeed interesting. The rounding error I can observe in one of my analysis (digesting millions of events) is negligible from and end user prospective, I just wanted to go at the bottom of it to understand what was causing it.&lt;/P&gt;
&lt;P&gt;Again thanks for your explanation and have a nice day!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 15:43:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Elapsed-time-approximation-error/m-p/2131455#M91973</guid>
      <dc:creator>steax</dc:creator>
      <dc:date>2023-10-24T15:43:55Z</dc:date>
    </item>
  </channel>
</rss>

