<?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 Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690523#M672903</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a calculation in a chart which works well using set analysis.&amp;nbsp; I want to get the calculation into the script as a new field for a variety of reasons which I won't bore you with...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm struggling to find an equivalent of the set analysis in the script.&amp;nbsp; I have one suggestion of how it can work but it seems very inefficient: I'd do an interval match to associate all the records (which the set analysis would define), and then group by to do my aggregation.&amp;nbsp; But that's growing my dataset 36x just to shrink it back again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there something with previous() or above() or peek() that I can use?&amp;nbsp; Sure there must be something out there!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is much appreciated, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Simplified situation (see attached QVW):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;One table, 2 fields: [month-end], [monthly return]. &lt;/P&gt;&lt;P&gt;For a given month-end, the standard deviation for 36 months to date needs to be calculated. &lt;/P&gt;&lt;P&gt;So we need a new table with 2 fields: [month-end], [36m standard deviation]. &lt;/P&gt;&lt;P&gt;Using set analysis this is possible in a chart (see QVW) - although I haven't yet tried making it work with a month-end dimension (have done it rather lazily with variables, to pin down a single month-end).&amp;nbsp; But how do I do it in the script?&amp;nbsp; &lt;/P&gt;&lt;P&gt;I could use some sort of intervalmatch to associate each month-end with 36 other month-ends leading up to it (say a field [associated month]), and then group by [month-end] and calculate stdev([monthly return]) which will be over 36 records.&amp;nbsp; But that grows my data 36x (in interval match) and then shrinks it again (in grouping).&amp;nbsp; Seems inefficient!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Sep 2014 07:56:29 GMT</pubDate>
    <dc:creator>sarahallen1</dc:creator>
    <dc:date>2014-09-25T07:56:29Z</dc:date>
    <item>
      <title>Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690523#M672903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a calculation in a chart which works well using set analysis.&amp;nbsp; I want to get the calculation into the script as a new field for a variety of reasons which I won't bore you with...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm struggling to find an equivalent of the set analysis in the script.&amp;nbsp; I have one suggestion of how it can work but it seems very inefficient: I'd do an interval match to associate all the records (which the set analysis would define), and then group by to do my aggregation.&amp;nbsp; But that's growing my dataset 36x just to shrink it back again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there something with previous() or above() or peek() that I can use?&amp;nbsp; Sure there must be something out there!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is much appreciated, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Simplified situation (see attached QVW):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;One table, 2 fields: [month-end], [monthly return]. &lt;/P&gt;&lt;P&gt;For a given month-end, the standard deviation for 36 months to date needs to be calculated. &lt;/P&gt;&lt;P&gt;So we need a new table with 2 fields: [month-end], [36m standard deviation]. &lt;/P&gt;&lt;P&gt;Using set analysis this is possible in a chart (see QVW) - although I haven't yet tried making it work with a month-end dimension (have done it rather lazily with variables, to pin down a single month-end).&amp;nbsp; But how do I do it in the script?&amp;nbsp; &lt;/P&gt;&lt;P&gt;I could use some sort of intervalmatch to associate each month-end with 36 other month-ends leading up to it (say a field [associated month]), and then group by [month-end] and calculate stdev([monthly return]) which will be over 36 records.&amp;nbsp; But that grows my data 36x (in interval match) and then shrinks it again (in grouping).&amp;nbsp; Seems inefficient!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 07:56:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690523#M672903</guid>
      <dc:creator>sarahallen1</dc:creator>
      <dc:date>2014-09-25T07:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690524#M672904</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 build a script to do this. Is this what you wanted?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 12:05:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690524#M672904</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-25T12:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690525#M672905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much for this!&amp;nbsp; It works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did not realise you could use aggregation functions like stdev in the script without a group by.&amp;nbsp; All the QV documentation I've seen says that the load statement has to be a group by for aggregations to be allowed.&amp;nbsp; I suppose what's happening in your script is the where clause gathers multiple records, and as you are not loading any fields based on single records, it kind of thinks it's a group (?!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, it baffled me a bit at first but I think I see how/why it works now, and the most important thing is that it does work!&amp;nbsp; So thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 15:26:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690525#M672905</guid>
      <dc:creator>sarahallen1</dc:creator>
      <dc:date>2014-09-25T15:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690526#M672906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to understand your logic.&lt;/P&gt;&lt;P&gt;If possible, can you pls explain what below logic will do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;Leer:&lt;/P&gt;
&lt;P&gt;load &lt;/P&gt;
&lt;P&gt;Null() as MonthEnd&lt;/P&gt;
&lt;P&gt;AutoGenerate(0); &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for i = 0 to (NoOfRows('36')-1)&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 15:47:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690526#M672906</guid>
      <dc:creator />
      <dc:date>2014-09-25T15:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690527#M672908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That bit just creates a blank table with one field (MonthEnd) but no records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I understand, it's just so there is something to concatenate to - if you look further down the script, within the loop (for each i.... next), it does a concatenation to the Leer table.&amp;nbsp; It builds up that table row by row.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 15:56:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690527#M672908</guid>
      <dc:creator>sarahallen1</dc:creator>
      <dc:date>2014-09-25T15:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690528#M672911</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;we don't need group by because we only have one logical MonthEnddate for each iteration, therefore we do not need to group by field values.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 16:03:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690528#M672911</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-25T16:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690529#M672914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you are right!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 16:07:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690529#M672914</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-25T16:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690530#M672918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I got it. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 16:24:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690530#M672918</guid>
      <dc:creator />
      <dc:date>2014-09-25T16:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation in script across multiple previous records WITHOUT intervalmatch/grouping?</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690531#M672921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The QVW I sent above was a simplified use case.&amp;nbsp; I've just realised that maybe I simplified it too much, but I have still managed to make it work - elaborating here in case other readers find it useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I simplified it because I removed another column in the original data, "fund" (each fund has it's own set of monthly returns).&amp;nbsp; I need this fund field to split up the data in the final table, as the stdev is calculated for each fund for each month-end, not just for each month-end.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My solution was to repeat the peek function to get another variable for the value of the field fund.&amp;nbsp; Same idea as the month-end peek variable - you're just reading values from a field, but can't do that in the load statement without it needing a group by statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 16:49:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-in-script-across-multiple-previous-records-WITHOUT/m-p/690531#M672921</guid>
      <dc:creator>sarahallen1</dc:creator>
      <dc:date>2014-09-25T16:49:32Z</dc:date>
    </item>
  </channel>
</rss>

