<?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 Calculating Age of Inventory in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculating-Age-of-Inventory/m-p/400534#M700377</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 a set of historical inventory and I am trying to calculate the age of inventory for each product resetting to 0 each time the&lt;BR /&gt;inventory reaches 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date, Product, Inventory are already in a table Exposure I loaded, and I am trying to add the Age column to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="26370" class="jive-image" alt="Exposure.PNG" src="https://community.qlik.com/legacyfs/online/26370_Exposure.PNG" /&gt;&lt;/P&gt;&lt;P&gt;From my research, it seems like I should Iterate with a condition that the previous Inventory for each Product is not null, but I am lost in the process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Dec 2012 14:17:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-12-03T14:17:14Z</dc:date>
    <item>
      <title>Calculating Age of Inventory</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Age-of-Inventory/m-p/400534#M700377</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 a set of historical inventory and I am trying to calculate the age of inventory for each product resetting to 0 each time the&lt;BR /&gt;inventory reaches 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date, Product, Inventory are already in a table Exposure I loaded, and I am trying to add the Age column to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="26370" class="jive-image" alt="Exposure.PNG" src="https://community.qlik.com/legacyfs/online/26370_Exposure.PNG" /&gt;&lt;/P&gt;&lt;P&gt;From my research, it seems like I should Iterate with a condition that the previous Inventory for each Product is not null, but I am lost in the process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2012 14:17:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Age-of-Inventory/m-p/400534#M700377</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-03T14:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Age of Inventory</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Age-of-Inventory/m-p/400535#M700378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You just need to sort your table by Product and Date and then use peek() function, e.g. along these lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Set DateFormat = 'DD/MM/YYYY';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;INPUT:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD * INLINE [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Date, Product, Inventory&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;03/12/2012,A,0&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;03/12/2012,B,10&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;03/12/2012,C,2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;04/12/2012,A,0&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;04/12/2012,B,10&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;04/12/2012,C,2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;05/12/2012,A,1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;05/12/2012,B,5&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;05/12/2012,C,0&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;06/12/2012,A,2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;06/12/2012,B,5&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;06/12/2012,C,1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;07/12/2012,A,2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;07/12/2012,B,5&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;07/12/2012,C,1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;RESULT:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD Date, Product, Inventory,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if(peek(Product) = Product and Inventory&amp;gt;0, rangesum(peek(Age),1),if(Inventory&amp;gt;0,1,0)) as Age&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Resident INPUT order by Product, Date;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;drop table INPUT;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S.&lt;/P&gt;&lt;P&gt;Posting some sample data is great! But it would be even better if you've posted it as text, so we are able to copy paste it, not as bitmap image (or even better formatted as INLINE LOAD or in sample qvw).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2012 15:45:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Age-of-Inventory/m-p/400535#M700378</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-12-03T15:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Age of Inventory</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Age-of-Inventory/m-p/400536#M700379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;P&gt;It works perfect.&lt;/P&gt;&lt;P&gt;Sorry for the image format of the table, I tried to copy and paste but it looked awful.&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2012 19:34:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Age-of-Inventory/m-p/400536#M700379</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-03T19:34:56Z</dc:date>
    </item>
  </channel>
</rss>

