<?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 Spot inventory split into years in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228674#M80680</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Syed's solution is simpler. I'd go with that. A couple slight revisions are required, I think. First, I think you need to use peek() to check the value of a field that isn't in your input table. Second, need to add an "else" to pick up the Change value in January:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;if(Year=previous(Year), &lt;STRONG&gt;peek&lt;/STRONG&gt;(NewField)+Change&lt;STRONG&gt;, Change&lt;/STRONG&gt;) as NewField&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Oct 2010 22:48:38 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2010-10-05T22:48:38Z</dc:date>
    <item>
      <title>Spot inventory split into years</title>
      <link>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228670#M80676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I'm trying to create an expression that would show spot inventory like in the below table. The spot inventory is a sum of a given line value and all the values above it within a year, next year it starts over and show only the given line value.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Year, Month, Change, &lt;STRONG&gt;Spot inventory&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2009, 10, 20, &lt;B&gt;20&lt;/B&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2009, 11, 21, &lt;B&gt;41&lt;/B&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2009, 12, 22, &lt;B&gt;63&lt;/B&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2010, 1, 31, &lt;B&gt;31&lt;/B&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2010, 2, -22, &lt;B&gt;9&lt;/B&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2010, 3, 33, &lt;B&gt;43&lt;/B&gt;&lt;/P&gt;&lt;P&gt;Any idea how to do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Przemek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 22:22:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228670#M80676</guid>
      <dc:creator />
      <dc:date>2010-10-05T22:22:34Z</dc:date>
    </item>
    <item>
      <title>Spot inventory split into years</title>
      <link>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228671#M80677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way is an AsOf table:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;AsOfMonth, InventoryType, Month&lt;BR /&gt;1, Spot, 1&lt;BR /&gt;1, Change, 1&lt;BR /&gt;2, Spot, 1&lt;BR /&gt;2, Spot, 2&lt;BR /&gt;2, Change, 2&lt;BR /&gt;3, Spot, 1&lt;BR /&gt;3, Spot, 2&lt;BR /&gt;3, Spot, 3&lt;BR /&gt;3, Change, 3&lt;BR /&gt;...&lt;BR /&gt;12, Spot, 11&lt;BR /&gt;12, Spot, 12&lt;BR /&gt;12, Change, 12&lt;/P&gt;&lt;P&gt;Then use a pivot table:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;dimension 1 (left) = Year&lt;BR /&gt;dimension 2 (left) = AsOfMonth&lt;BR /&gt;dimension 3 (top) = InventoryType&lt;BR /&gt;expression = sum(Change)&lt;/P&gt;&lt;P&gt;So for an inventory type of 'Change', it only links to the current month, so you get only the current Change value. For an inventory type of 'Spot', it links to the current month and all previous months, so you get the sum of all Change values up to that month of the year.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 22:32:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228671#M80677</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-10-05T22:32:21Z</dc:date>
    </item>
    <item>
      <title>Spot inventory split into years</title>
      <link>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228672#M80678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can do this while loading the script itself. Sort the table on Year and Month (if you have date then sort it on date). Then add another feild which keeps on adding the previous records value only if the Years of current an previous records are same. this way you can directly use the new feild in your table&lt;/P&gt;&lt;P&gt;eg: if(Year=previous(Year), Previous(NewField)+Change) as NewField&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Syed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 22:38:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228672#M80678</guid>
      <dc:creator>syed_muzammil</dc:creator>
      <dc:date>2010-10-05T22:38:22Z</dc:date>
    </item>
    <item>
      <title>Spot inventory split into years</title>
      <link>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228673#M80679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Than you, John. It seems to be a solution but I was hoping for something using above() function or similar. Do you have an idea how to do it this way?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 22:44:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228673#M80679</guid>
      <dc:creator />
      <dc:date>2010-10-05T22:44:30Z</dc:date>
    </item>
    <item>
      <title>Spot inventory split into years</title>
      <link>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228674#M80680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Syed's solution is simpler. I'd go with that. A couple slight revisions are required, I think. First, I think you need to use peek() to check the value of a field that isn't in your input table. Second, need to add an "else" to pick up the Change value in January:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;if(Year=previous(Year), &lt;STRONG&gt;peek&lt;/STRONG&gt;(NewField)+Change&lt;STRONG&gt;, Change&lt;/STRONG&gt;) as NewField&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 22:48:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228674#M80680</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-10-05T22:48:38Z</dc:date>
    </item>
    <item>
      <title>Spot inventory split into years</title>
      <link>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228675#M80681</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;przemek wrote:&lt;BR /&gt;Than you, John. It seems to be a solution but I was hoping for something using above() function or similar. Do you have an idea how to do it this way?&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Sure. Second expression, labeled 'Spot Inventory', this definition:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;rangesum(Change,above("Spot Inventory"))&lt;/P&gt;&lt;P&gt;But I wouldn't do it that way. If you then select a single month, for instance, it will set the spot inventory to only that month's change value, because the above() is looking at your chart, not at your data. You really want it to look at data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 22:53:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Spot-inventory-split-into-years/m-p/228675#M80681</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-10-05T22:53:09Z</dc:date>
    </item>
  </channel>
</rss>

