<?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 How to do moving averages over sparse timeseries data in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-do-moving-averages-over-sparse-timeseries-data/m-p/130515#M19664</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some sparse timeseries data where each row represents an event at a particular timestamp.&amp;nbsp; In addition to the raw timestamp, there is also an "Hour" column which is the timestamp truncated to the hour.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out an expression that will give me the number of events in the last X hours (24, for example).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A simple accumulation (or above()) won't work as the data is sparse and hours often have no data, especially with more specific selections.&amp;nbsp; Here is an example across the Hour dimension (continuous) showing the individual events counted by hour (blue bars) and then the same expression accumulating the previous 24 values (red line).&amp;nbsp; Clearly this isn't correct as the moving average does not decrease over the blank sections of the X-axis.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/216603_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It feels like there should be an easy solution for this, but I've failed to come up with one.&amp;nbsp; Options that I've explored are:&lt;/P&gt;&lt;P&gt;1. Set Analysis - couldn't figure this one out, not sure if it's possible&lt;/P&gt;&lt;P&gt;2. Making the data non-sparse - possible, but would result in a ton of empty rows as I'd have to insert all combinations of the various dimensions.&lt;/P&gt;&lt;P&gt;3. Playing around with the chart settings (Suppress Missing, Zero on Bars, etc.) - couldn't get anything to work.&amp;nbsp; Even if I could this seems like a hack vs. doing it in the expression itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached this sample qvw as well as the data used to create it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for any help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Oct 2018 19:08:27 GMT</pubDate>
    <dc:creator>bonotelscot</dc:creator>
    <dc:date>2018-10-23T19:08:27Z</dc:date>
    <item>
      <title>How to do moving averages over sparse timeseries data</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-moving-averages-over-sparse-timeseries-data/m-p/130515#M19664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some sparse timeseries data where each row represents an event at a particular timestamp.&amp;nbsp; In addition to the raw timestamp, there is also an "Hour" column which is the timestamp truncated to the hour.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out an expression that will give me the number of events in the last X hours (24, for example).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A simple accumulation (or above()) won't work as the data is sparse and hours often have no data, especially with more specific selections.&amp;nbsp; Here is an example across the Hour dimension (continuous) showing the individual events counted by hour (blue bars) and then the same expression accumulating the previous 24 values (red line).&amp;nbsp; Clearly this isn't correct as the moving average does not decrease over the blank sections of the X-axis.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/216603_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It feels like there should be an easy solution for this, but I've failed to come up with one.&amp;nbsp; Options that I've explored are:&lt;/P&gt;&lt;P&gt;1. Set Analysis - couldn't figure this one out, not sure if it's possible&lt;/P&gt;&lt;P&gt;2. Making the data non-sparse - possible, but would result in a ton of empty rows as I'd have to insert all combinations of the various dimensions.&lt;/P&gt;&lt;P&gt;3. Playing around with the chart settings (Suppress Missing, Zero on Bars, etc.) - couldn't get anything to work.&amp;nbsp; Even if I could this seems like a hack vs. doing it in the expression itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached this sample qvw as well as the data used to create it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for any help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2018 19:08:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-moving-averages-over-sparse-timeseries-data/m-p/130515#M19664</guid>
      <dc:creator>bonotelscot</dc:creator>
      <dc:date>2018-10-23T19:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to do moving averages over sparse timeseries data</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-do-moving-averages-over-sparse-timeseries-data/m-p/130516#M19665</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;one solution might be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_317725_Pic1.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/216818_QlikCommunity_Thread_317725_Pic1.JPG" style="height: 175px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_317725_Pic2.JPG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/216814_QlikCommunity_Thread_317725_Pic2.JPG" style="height: 161px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_317725_Pic3.JPG" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/216819_QlikCommunity_Thread_317725_Pic3.JPG" style="height: 309px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_317725_Pic4.JPG" class="image-4 jive-image" src="https://community.qlik.com/legacyfs/online/216820_QlikCommunity_Thread_317725_Pic4.JPG" style="height: 299px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15404988290323250" jivemacro_uid="_15404988290323250"&gt;
&lt;P&gt;table1:&lt;/P&gt;
&lt;P&gt;LOAD RecNo() as EventID,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timestamp, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hour, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim1, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim2, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim3, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim4, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Revenue&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;FROM [&lt;/SPAN&gt;&lt;A class="" data-containerid="-1" data-containertype="-1" data-objectid="341710" data-objecttype="13" href="https://community.qlik.com/servlet/JiveServlet/download/2051-317725-1562410-341710/sample_data.csv"&gt;https://community.qlik.com/servlet/JiveServlet/download/1562410-341710/sample_data.csv&lt;/A&gt;&lt;SPAN&gt;] (txt, codepage is 1252, embedded labels, delimiter is ',', msq);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;tabAsOfHour:&lt;/P&gt;
&lt;P&gt;LOAD Distinct&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hour,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timestamp#(Timestamp(Hour+(IterNo()-1)*'01:00:00','MM/DD/YYYY hh:mm:ss'),'MM/DD/YYYY hh:mm:ss') as AsOfHour,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IterNo() as IntervalHours&lt;/P&gt;
&lt;P&gt;Resident table1&lt;/P&gt;
&lt;P&gt;While IterNo()&amp;lt;=24;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;see also:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4531"&gt;The As-Of Table&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&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;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2018 20:21:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-do-moving-averages-over-sparse-timeseries-data/m-p/130516#M19665</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2018-10-25T20:21:05Z</dc:date>
    </item>
  </channel>
</rss>

