<?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 AW:Re: AW:Re: Aggregation over more then 1 field with script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229658#M81551</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thank you very much ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;P&gt;As I tested the rangesum() in script editor with peek() like your solution, I thought, that I have to take a existing field (red marked):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;,rangesum(bestand1,if(Artikel=previous(Artikel),peek(bestand1))) as bestand2&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second issue is, that the name of the calculated field also has to be named like the green marked "variable". Otherwise the function rangesum() do not work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;,rangesum(bestand1,if(Artikel=previous(Artikel),peek(xyz))) as xyz&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Where could I get this information? I looked up in the help file and the manual, but this stood nowhere &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Dec 2010 18:23:24 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-12-22T18:23:24Z</dc:date>
    <item>
      <title>Aggregation over more then 1 field with script</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229654#M81547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hallo QV Community,&lt;/P&gt;&lt;P&gt;I can not find out how to aggregate over more the one field with a script. In the application there ist the rangesum() function, which ist very helpful, but do not show the result I whish. I have build a simple sample, which shows the table to begin: In the period (Periode) 0 has every article (Artikel) a begining inventory value (bestand1).&lt;/P&gt;&lt;P&gt;&lt;IMG border="0" src="https://community.qlik.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Discussions.Components.Files/11/7571.Tabelle_5F00_Bestand_5F00_1.jpg" /&gt;&lt;/P&gt;&lt;P&gt;Now I want to generate a table with following result:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error loading image" class="jive-image error-loading-image" src="https://community.qlik.com/legacyfs/online/-3114_sourceID:3114" /&gt;&lt;/P&gt;&lt;P&gt;For each period and article the values should be aggregated: (article a1 for example:)&lt;/P&gt;&lt;P&gt;150 [period 0]+ (-35)[period1] = 115 + (-1)[period3] = 114 + (-9)[period6] =103&lt;/P&gt;&lt;P&gt;I think that must be very simple, but can not find out how...&lt;/P&gt;&lt;P&gt;Can someone help me?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Dec 2010 18:05:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229654#M81547</guid>
      <dc:creator />
      <dc:date>2010-12-21T18:05:45Z</dc:date>
    </item>
    <item>
      <title>Aggregation over more then 1 field with script</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229655#M81548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LOAD&lt;BR /&gt; Periode&lt;BR /&gt;,Artikel&lt;BR /&gt;,rangesum(bestand1,if(Artikel=previous(Artikel),previous(bestand))) as bestand&lt;BR /&gt;FROM wherever&lt;BR /&gt;ORDER BY Artikel, Periode&lt;BR /&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Dec 2010 01:59:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229655#M81548</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-12-22T01:59:22Z</dc:date>
    </item>
    <item>
      <title>AW:Re: Aggregation over more then 1 field with script</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229656#M81549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your idea, but it does not generate the result i need. The first step ist to sort the table for 'Artikel' and 'Period' like your suggestion:&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/6406.Tabelle_5F00_Bestand_5F00_sortiert.jpg"&gt;&lt;IMG alt="" border="0" src="http://community.qlik.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Discussions.Components.Files/11/6406.Tabelle_5F00_Bestand_5F00_sortiert.jpg" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But then I think, that we need a variable which saves the calculated value. Then using this variable in a do while function approximately:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;let v_bestand = '0';&lt;BR /&gt;load Artikel, Period,&lt;BR /&gt;do while { Artikel=previous(Artikel)&lt;BR /&gt; ($(v_bestand)=$(v_bestand)+bestand1) as bestand2&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; $(v_bestand) = 0&lt;BR /&gt; bestand1 as bestand2&lt;BR /&gt; }&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;I don't know ho to write this in correct qlikview syntax. (PS: How can I remove the space in new lines?)&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Dec 2010 11:55:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229656#M81549</guid>
      <dc:creator />
      <dc:date>2010-12-22T11:55:54Z</dc:date>
    </item>
    <item>
      <title>AW:Re: Aggregation over more then 1 field with script</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229657#M81550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry. One of the previous() needed to be peek(). That fixed, it produces the table you requested, other than 6 a1 which you miscalculated (114 - 9 = 105, not 103). You don't need a variable, you don't need to save the calculated value (it's already saved in the previous row of your output table), and you don't need a do while loop. All you need to do is reference the previous value in the OUTPUT table, which is what peek() does, while previous() references the previous value in the INPUT table. I appear to have confused these in my previous post.&lt;/P&gt;&lt;P&gt;See attached.&lt;/P&gt;&lt;P&gt;As for removing the spaces in the new lines, either cut and past into notepad and then into your post, or go into settings -&amp;gt; user preferences -&amp;gt; editor, and remove the checkmark next to "copy as RTF". Any editing in the post itself will I think reinsert blank lines. There's probably a way around that somewhere in the preferences for the site.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Dec 2010 17:43:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229657#M81550</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-12-22T17:43:50Z</dc:date>
    </item>
    <item>
      <title>AW:Re: AW:Re: Aggregation over more then 1 field with script</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229658#M81551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thank you very much ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;P&gt;As I tested the rangesum() in script editor with peek() like your solution, I thought, that I have to take a existing field (red marked):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;,rangesum(bestand1,if(Artikel=previous(Artikel),peek(bestand1))) as bestand2&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second issue is, that the name of the calculated field also has to be named like the green marked "variable". Otherwise the function rangesum() do not work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;,rangesum(bestand1,if(Artikel=previous(Artikel),peek(xyz))) as xyz&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Where could I get this information? I looked up in the help file and the manual, but this stood nowhere &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Dec 2010 18:23:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229658#M81551</guid>
      <dc:creator />
      <dc:date>2010-12-22T18:23:24Z</dc:date>
    </item>
    <item>
      <title>AW:Re: AW:Re: Aggregation over more then 1 field with script</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229659#M81552</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;TimurVogel wrote:Where could I get this information?&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I'm not sure there's anything that will tell you which field names and functions to use to produce your desired result. It's just a matter of experience with QlikView, I think. The forums are usually a good resource when you're stuck, or even if you figure out a way to do it, but it seems inelegant to you. Sometimes you just need to do something inelegant, but sometimes there's a more elegant way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Dec 2010 18:33:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-over-more-then-1-field-with-script/m-p/229659#M81552</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-12-22T18:33:15Z</dc:date>
    </item>
  </channel>
</rss>

