<?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 moving average of items on time dimension in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199290#M58276</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry John,&lt;/P&gt;&lt;P&gt;I think I'm not good enough in QlikView to understand your suggestion correctly &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I really appreciate your help - thx a lot!!&lt;/P&gt;&lt;P&gt;Using Your suggestion in the script&lt;/P&gt;&lt;P style="font-style: italic"&gt;timestamp(rangesum(EVENT_TIME,if(EVENT_TIME=previous(EVENT_TIME),time#('00:00:00.001','hh:mm:ss.fff'))),'YYYY-MM-DD hh:mm:ss.fff') as EVENT_TIME2&lt;/P&gt;&lt;P&gt;creates the same millisecond for all the following items within one minute.&lt;/P&gt;&lt;P&gt;Let me try to explain how I understand your suggestion:&lt;/P&gt;&lt;P&gt;FIRST timestamp:&lt;/P&gt;&lt;P&gt;timestamp( //create a timestamp&lt;BR /&gt; rangesum(EVENT_TIME,if(EVENT_TIME=previous(EVENT_TIME),time#('00:00:00.001','hh:mm:ss.fff'))) //value of the timestamp to be created&lt;BR /&gt; ,'YYYY-MM-DD hh:mm:ss.fff' //format of the timestampto be created&lt;BR /&gt;) as EVENT_TIME2&lt;/P&gt;&lt;P&gt;SECOND rangesum:&lt;/P&gt;&lt;P&gt;rangesum( // add the values within brackets&lt;BR /&gt; EVENT_TIME, // EVENT_TIME as summand one&lt;BR /&gt; if(EVENT_TIME=previous(EVENT_TIME),time#('00:00:00.001','hh:mm:ss.fff')) //one millisecond as summand two&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;Executing this in a script means adding one milisecond to a identical prevous EVENT_TIME.&lt;/P&gt;&lt;P&gt;Example: running through:&lt;/P&gt;&lt;P&gt;0,2010-06-09 03:45,good&lt;BR /&gt;1,2010-06-09 03:56,good&lt;BR /&gt;2,2010-06-09 03:56,good&lt;BR /&gt;3,2010-06-09 03:56,good&lt;BR /&gt;4,2010-06-09 03:56,good&lt;/P&gt;&lt;P&gt;Looking at 1: 2010-06-09 03:56 is NOT identical to previous 2010-06-09 03:45, RESULT is 2010-06-09 03:56 as timestamp = 2010-06-09 03:56:00.000&lt;/P&gt;&lt;P&gt;Looking at 2: 2010-06-09 03:56 IS identical to previous 2010-06-09 03:56, RESULT is 2010-06-09 03:56 + 00:00:00.001 as timestamp = 2010-06-09 03:56:00.001 GREAT!&lt;/P&gt;&lt;P&gt;Looking at 3: 2010-06-09 03:56 IS AGAIN identical to previous 2010-06-09 03:56, RESULT is 2010-06-09 03:56 + 00:00:00.001 as timestamp = 2010-06-09 03:56:00.001 BAD. It should be 2010-06-09 03:56:00.002, because it is the second identical match.&lt;/P&gt;&lt;P&gt;That's why I was asking fpr a recursive solution.&lt;/P&gt;&lt;P&gt;Did I miss anything in your post?&lt;/P&gt;&lt;P&gt;I can't see how 60.000 different values can be created????&lt;/P&gt;&lt;P&gt;Thx again!&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Jun 2010 15:36:20 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-06-25T15:36:20Z</dc:date>
    <item>
      <title>moving average of items on time dimension</title>
      <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199286#M58272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;my task is to create a Line-Chart where an sliding average is displayed over a time axis.&lt;/P&gt;&lt;P&gt;The time axis should display an "night working shift" which starts at 22:20h and stops the next day day 06:20h.&lt;/P&gt;&lt;P&gt;Each item has a EVENT-Time "minute" which has precision in minutes. But there might be several items within the same minute.&lt;/P&gt;&lt;P&gt;Each item has a unique "ID" (a 10-digit number) which also represents the sequence of the items.&lt;/P&gt;&lt;P&gt;Each item has a "quality" [good/bad]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have to do is the following:&lt;/P&gt;&lt;P&gt;Find the good items within the last 20 items (regarding used filters so I can' t do it at load time) and divide the result by 20 and display it on a time X-Axis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current solution:&lt;/P&gt;&lt;P&gt;As I want to calculate the fraction of the last 20 good items to all last 20 items I am trying it with a rangecount expression where EVERY item occurs:&lt;/P&gt;&lt;P&gt;rangesum(above(count({&amp;lt;QUALITY = {'good'}&amp;gt;}ID),1,20))&lt;BR /&gt;/&lt;BR /&gt;rangesum(above(count(ID),1,20))&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This works fine. The chart is correct.&lt;/P&gt;&lt;P&gt;BUT what I need is the Timeline on the x-Axis....&lt;/P&gt;&lt;P&gt;Is there any help?&lt;/P&gt;&lt;P&gt;Thx in advance!&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jun 2010 13:06:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199286#M58272</guid>
      <dc:creator />
      <dc:date>2010-06-23T13:06:52Z</dc:date>
    </item>
    <item>
      <title>moving average of items on time dimension</title>
      <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199287#M58273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you're almost there, but I think you need a new timestamp field. Your event time is only accurate to the minute, but your ID indicates sequence within the minute. That sequence is important when you want the average of the last 20 items, so I think you need to map these IDs to separate timestamps (to indicate sequence) instead of to the same timestamp. For instance, create this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;timestamp(rangesum(EVENT_TIME,if(EVENT_TIME=previous(EVENT_TIME),time#('00:00:00.001','hh:mm:ss.fff'))),'YYYY-MM-DD hh:mm:ss.fff') as EVENT_TIME2&lt;/P&gt;&lt;P&gt;And wouldn't you also want the current ID counted at its own timestamp? If so, I think you want above(...,0,20) instead of above(...,1,20). So this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;rangesum(above(count({&amp;lt;QUALITY={'good'}&amp;gt;}ID),0,20))&lt;BR /&gt;/rangesum(above(count(ID),0,20))&lt;/P&gt;&lt;P&gt;And finally, use EVENT_TIMESTAMP2 as your dimension, and set the X axis to continuous. That seems to produce the graph that I think you want.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jun 2010 21:07:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199287#M58273</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-06-23T21:07:50Z</dc:date>
    </item>
    <item>
      <title>moving average of items on time dimension</title>
      <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199288#M58274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;yes that is the way I thought I'd have to do it. As there might be several items within on minute I did the following, which works fine, but what if there are more than 5 items in one minute? Is there a recursive chance to solve that?&lt;/P&gt;&lt;P&gt;An another question: Changing the Format Pattern of time for the conituous axis to 'HH:mm' does not take any effect. I'm working on 9.0 SR3. Is it a bug?&lt;/P&gt;&lt;P&gt;MyData:&lt;BR /&gt;Load&lt;BR /&gt; ID,&lt;BR /&gt; EVENT_TIME,&lt;BR /&gt; QUALITY,&lt;BR /&gt; if (EVENT_TIME = previous(EVENT_TIME),&lt;BR /&gt; if (EVENT_TIME = previous(previous(EVENT_TIME)),&lt;BR /&gt; if (EVENT_TIME = previous(previous(previous(EVENT_TIME))),&lt;BR /&gt; if (EVENT_TIME = previous(previous(previous(EVENT_TIME))),&lt;BR /&gt; if (EVENT_TIME = previous(previous(previous(EVENT_TIME))),&lt;BR /&gt; timestamp(EVENT_TIME &amp;amp; ':05', 'YYYY-MM-DD hh:mm:ss'),&lt;BR /&gt; timestamp(EVENT_TIME &amp;amp; ':04', 'YYYY-MM-DD hh:mm:ss')&lt;BR /&gt; ),&lt;BR /&gt; timestamp(EVENT_TIME &amp;amp; ':03', 'YYYY-MM-DD hh:mm:ss')&lt;BR /&gt; ),&lt;BR /&gt; timestamp(EVENT_TIME &amp;amp; ':02', 'YYYY-MM-DD hh:mm:ss')&lt;BR /&gt; ),&lt;BR /&gt; timestamp(EVENT_TIME &amp;amp; ':01', 'YYYY-MM-DD hh:mm:ss')&lt;BR /&gt; ),&lt;BR /&gt; timestamp(EVENT_TIME &amp;amp; ':00', 'YYYY-MM-DD hh:mm:ss')&lt;BR /&gt; ) as timeIdent&lt;BR /&gt;&lt;BR /&gt;Resident BaseData&lt;BR /&gt;order by EVENT_TIME ASC, ID ASC;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jun 2010 11:41:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199288#M58274</guid>
      <dc:creator />
      <dc:date>2010-06-24T11:41:59Z</dc:date>
    </item>
    <item>
      <title>moving average of items on time dimension</title>
      <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199289#M58275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;BR /&gt;martin.goettler wrote:I did the following, which works fine, but what if there are more than 5 items in one minute? Is there a recursive chance to solve that?&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I already gave a solution, and it handles 60,000 events in the same minute instead of 5, unless you see a bug in it, and that's why you were trying to write your own version?&lt;/P&gt;&lt;P&gt;As for why it won't format the continuous X-axis like you tell it to, that I don't know. Seems strange. Yeah, might be a bug, but if so, it isn't fixed with SR4 either, because I couldn't get it to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jun 2010 17:15:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199289#M58275</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-06-24T17:15:52Z</dc:date>
    </item>
    <item>
      <title>moving average of items on time dimension</title>
      <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199290#M58276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry John,&lt;/P&gt;&lt;P&gt;I think I'm not good enough in QlikView to understand your suggestion correctly &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I really appreciate your help - thx a lot!!&lt;/P&gt;&lt;P&gt;Using Your suggestion in the script&lt;/P&gt;&lt;P style="font-style: italic"&gt;timestamp(rangesum(EVENT_TIME,if(EVENT_TIME=previous(EVENT_TIME),time#('00:00:00.001','hh:mm:ss.fff'))),'YYYY-MM-DD hh:mm:ss.fff') as EVENT_TIME2&lt;/P&gt;&lt;P&gt;creates the same millisecond for all the following items within one minute.&lt;/P&gt;&lt;P&gt;Let me try to explain how I understand your suggestion:&lt;/P&gt;&lt;P&gt;FIRST timestamp:&lt;/P&gt;&lt;P&gt;timestamp( //create a timestamp&lt;BR /&gt; rangesum(EVENT_TIME,if(EVENT_TIME=previous(EVENT_TIME),time#('00:00:00.001','hh:mm:ss.fff'))) //value of the timestamp to be created&lt;BR /&gt; ,'YYYY-MM-DD hh:mm:ss.fff' //format of the timestampto be created&lt;BR /&gt;) as EVENT_TIME2&lt;/P&gt;&lt;P&gt;SECOND rangesum:&lt;/P&gt;&lt;P&gt;rangesum( // add the values within brackets&lt;BR /&gt; EVENT_TIME, // EVENT_TIME as summand one&lt;BR /&gt; if(EVENT_TIME=previous(EVENT_TIME),time#('00:00:00.001','hh:mm:ss.fff')) //one millisecond as summand two&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;Executing this in a script means adding one milisecond to a identical prevous EVENT_TIME.&lt;/P&gt;&lt;P&gt;Example: running through:&lt;/P&gt;&lt;P&gt;0,2010-06-09 03:45,good&lt;BR /&gt;1,2010-06-09 03:56,good&lt;BR /&gt;2,2010-06-09 03:56,good&lt;BR /&gt;3,2010-06-09 03:56,good&lt;BR /&gt;4,2010-06-09 03:56,good&lt;/P&gt;&lt;P&gt;Looking at 1: 2010-06-09 03:56 is NOT identical to previous 2010-06-09 03:45, RESULT is 2010-06-09 03:56 as timestamp = 2010-06-09 03:56:00.000&lt;/P&gt;&lt;P&gt;Looking at 2: 2010-06-09 03:56 IS identical to previous 2010-06-09 03:56, RESULT is 2010-06-09 03:56 + 00:00:00.001 as timestamp = 2010-06-09 03:56:00.001 GREAT!&lt;/P&gt;&lt;P&gt;Looking at 3: 2010-06-09 03:56 IS AGAIN identical to previous 2010-06-09 03:56, RESULT is 2010-06-09 03:56 + 00:00:00.001 as timestamp = 2010-06-09 03:56:00.001 BAD. It should be 2010-06-09 03:56:00.002, because it is the second identical match.&lt;/P&gt;&lt;P&gt;That's why I was asking fpr a recursive solution.&lt;/P&gt;&lt;P&gt;Did I miss anything in your post?&lt;/P&gt;&lt;P&gt;I can't see how 60.000 different values can be created????&lt;/P&gt;&lt;P&gt;Thx again!&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jun 2010 15:36:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199290#M58276</guid>
      <dc:creator />
      <dc:date>2010-06-25T15:36:20Z</dc:date>
    </item>
    <item>
      <title>moving average of items on time dimension</title>
      <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199291#M58277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, you're right, my suggestion WAS broken. Sorry about that.&lt;/P&gt;&lt;P&gt;Fortunately, it's easily fixed by incrementing from the timestamp we're creating instead of from the one we're reading in. The critical piece missing from the previous incorrect solution is underlined:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;timestamp(if(EVENT_TIME=previous(EVENT_TIME)&lt;BR /&gt; ,&lt;STRONG&gt;peek(timeIdent)&lt;/STRONG&gt;+time#('00:00:00.001','hh:mm:ss.fff')&lt;BR /&gt; ,EVENT_TIME),'YYYY-MM-DD hh:mm:ss.fff') as timeIdent&lt;/P&gt;&lt;P&gt;And this time I tested with four same EVENT_TIMEs instead of just with two. Appeared to work fine, though glancing at the results for five seconds isn't proof of a working algorithm.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jun 2010 17:10:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199291#M58277</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-06-25T17:10:34Z</dc:date>
    </item>
    <item>
      <title>moving average of items on time dimension</title>
      <link>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199292#M58278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thx John!&lt;/P&gt;&lt;P&gt;this solutions works perfectly!&lt;/P&gt;&lt;P&gt;Sorry about the delay but the project came up heavy &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Good job again - I do find many of your solutions in the forum very helpful!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Me as a newbie needs a trainer like you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jul 2010 09:59:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/moving-average-of-items-on-time-dimension/m-p/199292#M58278</guid>
      <dc:creator />
      <dc:date>2010-07-21T09:59:31Z</dc:date>
    </item>
  </channel>
</rss>

