<?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 Countdown of stock in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Countdown-of-stock/m-p/161663#M35466</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 had posted previously, and John supplied me with some code that really helped, but I believe I need some further assistance…&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; mso-bidi-font-weight: normal"&gt;Scenario:&lt;/P&gt;&lt;P&gt;I am trying to calculate the number of week's stock I have for each product based on the stock available against the forecast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The forecast is extracted from a 52 week array, in a field called Qty. Within a table called Inventory, I have fields for Available Stock, Required, On Hand and On Order. These need to be calculated into my available stock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The forecast is in calendar months, years 2008 - 2010 in 52 weeks. I need QlikView to work out what current week we are in, as I need it to count down from there. I then need QlikView to countdown my stock levels, updating the amount for each week until 0, showing what week it will run out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The inventory table is a standard figure which is updated real time (no time period).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code John originally supplied was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Inventory]:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Stock Item, Week, Forecast Amount&lt;BR /&gt;1, 1, 20&lt;BR /&gt;1, 2, 10&lt;BR /&gt;1, 3, 30&lt;BR /&gt;1, 4, 60&lt;BR /&gt;1, 5, 10&lt;BR /&gt;2, 1, 1&lt;BR /&gt;2, 2, 2&lt;BR /&gt;2, 3, 3&lt;BR /&gt;2, 4, 5&lt;BR /&gt;2, 5, 8&lt;BR /&gt;2, 6, 13&lt;BR /&gt;2, 7, 21&lt;BR /&gt;2, 8, 34&lt;BR /&gt;2, 9, 55&lt;BR /&gt;2,10, 89&lt;BR /&gt;3, 1, 10&lt;BR /&gt;3, 2, 10&lt;BR /&gt;3, 3, 10&lt;BR /&gt;3, 4, 10&lt;BR /&gt;3, 5, 10&lt;BR /&gt;3, 6, 10&lt;BR /&gt;3, 7, 10&lt;BR /&gt;3, 8, 10&lt;BR /&gt;3, 9, 10&lt;BR /&gt;3,10, 10&lt;BR /&gt;3,11, 10]&lt;BR /&gt;;&lt;BR /&gt;LEFT JOIN&lt;BR /&gt;LOAD&lt;BR /&gt; "Stock Item"&lt;BR /&gt;,"Week"&lt;BR /&gt;,rangemax(0,if("Week"=1,ceil(rand()*100),peek("Available")-previous("Forecast Amount"))) as "Available"&lt;BR /&gt;RESIDENT [Inventory]&lt;BR /&gt;;&lt;BR /&gt;[Weeks of Stock]:&lt;BR /&gt;LOAD&lt;BR /&gt; "Stock Item"&lt;BR /&gt;,min("Week") - 1 as "Weeks Available"&lt;BR /&gt;RESIDENT [Inventory]&lt;BR /&gt;WHERE "Available" &amp;lt;= 0&lt;BR /&gt;GROUP BY "Stock Item"&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which I integrated to make:&lt;/P&gt;&lt;P style="font-style: italic"&gt;Inventory:&lt;/P&gt;&lt;P&gt;&lt;B&gt;LOAD&lt;/B&gt; "in_domain",&lt;/P&gt;&lt;P&gt;"in_part" &lt;B&gt;as&lt;/B&gt; Part,&lt;/P&gt;&lt;P&gt;"in_qty_all" &lt;B&gt;as&lt;/B&gt; Quantity,&lt;/P&gt;&lt;P&gt;"in_qty_avail" &lt;B&gt;as&lt;/B&gt; AvailableStock,&lt;/P&gt;&lt;P&gt;"in_qty_chg" &lt;B&gt;as&lt;/B&gt; Changed,&lt;/P&gt;&lt;P&gt;"in_qty_oh" &lt;B&gt;As&lt;/B&gt; [On Hand],&lt;/P&gt;&lt;P&gt;"in_qty_ord" &lt;B&gt;as&lt;/B&gt; Ordered,&lt;/P&gt;&lt;P&gt;"in_qty_req" &lt;B&gt;as&lt;/B&gt; Required,&lt;/P&gt;&lt;P&gt;"in_site";&lt;/P&gt;&lt;P&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt; "in_domain",&lt;/P&gt;&lt;P&gt;"in_part",&lt;/P&gt;&lt;P&gt;"in_qty_all",&lt;/P&gt;&lt;P&gt;"in_qty_avail",&lt;/P&gt;&lt;P&gt;"in_qty_chg",&lt;/P&gt;&lt;P&gt;"in_qty_oh",&lt;/P&gt;&lt;P&gt;"in_qty_ord",&lt;/P&gt;&lt;P&gt;"in_qty_req",&lt;/P&gt;&lt;P&gt;"in_site"&lt;/P&gt;&lt;P&gt;&lt;B&gt;FROM&lt;/B&gt; PUB."in_mstr";&lt;/P&gt;&lt;P style="font-style: italic"&gt;TempForecast:&lt;/P&gt;&lt;P&gt;&lt;B&gt;LOAD&lt;/B&gt; fcs_fcst_qty &lt;B&gt;as&lt;/B&gt; Qty,&lt;/P&gt;&lt;P&gt;"fcs_year" &lt;B&gt;as&lt;/B&gt; Year,&lt;/P&gt;&lt;P&gt;"fcs_part" &lt;B&gt;as&lt;/B&gt; Part;&lt;/P&gt;&lt;P&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt;&lt;/P&gt;&lt;P&gt;"fcs_fcst_qty",&lt;/P&gt;&lt;P&gt;"fcs_part",&lt;/P&gt;&lt;P&gt;"fcs_year"&lt;/P&gt;&lt;P&gt;&lt;B&gt;FROM&lt;/B&gt; PUB."fcs_sum";&lt;/P&gt;&lt;P&gt;&lt;B&gt;Join&lt;/B&gt; (&lt;I&gt;Inventory&lt;/I&gt;)&lt;/P&gt;&lt;P&gt;&lt;B&gt;Load&lt;/B&gt; Part,&lt;/P&gt;&lt;P&gt;Year,&lt;/P&gt;&lt;P&gt;Year&amp;amp;'.'&amp;amp;num(iterno(),'00') &lt;B&gt;as&lt;/B&gt; YearWeek,&lt;/P&gt;&lt;P&gt;Subfield(Qty,';',Iterno()) &lt;B&gt;as&lt;/B&gt; Qty,&lt;/P&gt;&lt;P&gt;Iterno() &lt;B&gt;as&lt;/B&gt; Week&lt;/P&gt;&lt;P&gt;&lt;B&gt;Resident&lt;/B&gt; TempForecast&lt;/P&gt;&lt;P&gt;&lt;B&gt;WHILE&lt;/B&gt; iterno()&amp;lt;substringcount(Qty,';')+2;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Drop&lt;/B&gt; &lt;B&gt;Table&lt;/B&gt; &lt;I&gt;TempForecast;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;LEFT&lt;/B&gt; &lt;B&gt;JOIN&lt;/B&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;LOAD&lt;/P&gt;&lt;P&gt;Part&lt;/P&gt;&lt;P&gt;,"Week"&lt;/P&gt;&lt;P&gt;,rangemax(0,if("Week"=1,ceil(rand()*100),peek("Available")-previous("Qty"))) &lt;B&gt;as&lt;/B&gt; "Available"&lt;/P&gt;&lt;P&gt;&lt;B&gt;RESIDENT&lt;/B&gt; [Inventory]&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P style="font-style: italic"&gt;[Weeks of Stock]:&lt;/P&gt;&lt;P style="font-weight: bold"&gt;LOAD&lt;/P&gt;&lt;P&gt;Part&lt;/P&gt;&lt;P&gt;,min("Week") - 1 &lt;B&gt;as&lt;/B&gt; "Weeks Available"&lt;/P&gt;&lt;P&gt;&lt;B&gt;RESIDENT&lt;/B&gt; [Inventory]&lt;/P&gt;&lt;P&gt;&lt;B&gt;WHERE&lt;/B&gt; "Available" &amp;lt;= 0&lt;/P&gt;&lt;P&gt;&lt;B&gt;GROUP&lt;/B&gt; &lt;B&gt;BY&lt;/B&gt; Part&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're help will be muchly appreciated!!!&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Dayna Litherland&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Aug 2009 15:55:30 GMT</pubDate>
    <dc:creator>Dayna</dc:creator>
    <dc:date>2009-08-20T15:55:30Z</dc:date>
    <item>
      <title>Countdown of stock</title>
      <link>https://community.qlik.com/t5/QlikView/Countdown-of-stock/m-p/161663#M35466</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 had posted previously, and John supplied me with some code that really helped, but I believe I need some further assistance…&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold; mso-bidi-font-weight: normal"&gt;Scenario:&lt;/P&gt;&lt;P&gt;I am trying to calculate the number of week's stock I have for each product based on the stock available against the forecast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The forecast is extracted from a 52 week array, in a field called Qty. Within a table called Inventory, I have fields for Available Stock, Required, On Hand and On Order. These need to be calculated into my available stock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The forecast is in calendar months, years 2008 - 2010 in 52 weeks. I need QlikView to work out what current week we are in, as I need it to count down from there. I then need QlikView to countdown my stock levels, updating the amount for each week until 0, showing what week it will run out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The inventory table is a standard figure which is updated real time (no time period).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code John originally supplied was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Inventory]:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Stock Item, Week, Forecast Amount&lt;BR /&gt;1, 1, 20&lt;BR /&gt;1, 2, 10&lt;BR /&gt;1, 3, 30&lt;BR /&gt;1, 4, 60&lt;BR /&gt;1, 5, 10&lt;BR /&gt;2, 1, 1&lt;BR /&gt;2, 2, 2&lt;BR /&gt;2, 3, 3&lt;BR /&gt;2, 4, 5&lt;BR /&gt;2, 5, 8&lt;BR /&gt;2, 6, 13&lt;BR /&gt;2, 7, 21&lt;BR /&gt;2, 8, 34&lt;BR /&gt;2, 9, 55&lt;BR /&gt;2,10, 89&lt;BR /&gt;3, 1, 10&lt;BR /&gt;3, 2, 10&lt;BR /&gt;3, 3, 10&lt;BR /&gt;3, 4, 10&lt;BR /&gt;3, 5, 10&lt;BR /&gt;3, 6, 10&lt;BR /&gt;3, 7, 10&lt;BR /&gt;3, 8, 10&lt;BR /&gt;3, 9, 10&lt;BR /&gt;3,10, 10&lt;BR /&gt;3,11, 10]&lt;BR /&gt;;&lt;BR /&gt;LEFT JOIN&lt;BR /&gt;LOAD&lt;BR /&gt; "Stock Item"&lt;BR /&gt;,"Week"&lt;BR /&gt;,rangemax(0,if("Week"=1,ceil(rand()*100),peek("Available")-previous("Forecast Amount"))) as "Available"&lt;BR /&gt;RESIDENT [Inventory]&lt;BR /&gt;;&lt;BR /&gt;[Weeks of Stock]:&lt;BR /&gt;LOAD&lt;BR /&gt; "Stock Item"&lt;BR /&gt;,min("Week") - 1 as "Weeks Available"&lt;BR /&gt;RESIDENT [Inventory]&lt;BR /&gt;WHERE "Available" &amp;lt;= 0&lt;BR /&gt;GROUP BY "Stock Item"&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which I integrated to make:&lt;/P&gt;&lt;P style="font-style: italic"&gt;Inventory:&lt;/P&gt;&lt;P&gt;&lt;B&gt;LOAD&lt;/B&gt; "in_domain",&lt;/P&gt;&lt;P&gt;"in_part" &lt;B&gt;as&lt;/B&gt; Part,&lt;/P&gt;&lt;P&gt;"in_qty_all" &lt;B&gt;as&lt;/B&gt; Quantity,&lt;/P&gt;&lt;P&gt;"in_qty_avail" &lt;B&gt;as&lt;/B&gt; AvailableStock,&lt;/P&gt;&lt;P&gt;"in_qty_chg" &lt;B&gt;as&lt;/B&gt; Changed,&lt;/P&gt;&lt;P&gt;"in_qty_oh" &lt;B&gt;As&lt;/B&gt; [On Hand],&lt;/P&gt;&lt;P&gt;"in_qty_ord" &lt;B&gt;as&lt;/B&gt; Ordered,&lt;/P&gt;&lt;P&gt;"in_qty_req" &lt;B&gt;as&lt;/B&gt; Required,&lt;/P&gt;&lt;P&gt;"in_site";&lt;/P&gt;&lt;P&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt; "in_domain",&lt;/P&gt;&lt;P&gt;"in_part",&lt;/P&gt;&lt;P&gt;"in_qty_all",&lt;/P&gt;&lt;P&gt;"in_qty_avail",&lt;/P&gt;&lt;P&gt;"in_qty_chg",&lt;/P&gt;&lt;P&gt;"in_qty_oh",&lt;/P&gt;&lt;P&gt;"in_qty_ord",&lt;/P&gt;&lt;P&gt;"in_qty_req",&lt;/P&gt;&lt;P&gt;"in_site"&lt;/P&gt;&lt;P&gt;&lt;B&gt;FROM&lt;/B&gt; PUB."in_mstr";&lt;/P&gt;&lt;P style="font-style: italic"&gt;TempForecast:&lt;/P&gt;&lt;P&gt;&lt;B&gt;LOAD&lt;/B&gt; fcs_fcst_qty &lt;B&gt;as&lt;/B&gt; Qty,&lt;/P&gt;&lt;P&gt;"fcs_year" &lt;B&gt;as&lt;/B&gt; Year,&lt;/P&gt;&lt;P&gt;"fcs_part" &lt;B&gt;as&lt;/B&gt; Part;&lt;/P&gt;&lt;P&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt;&lt;/P&gt;&lt;P&gt;"fcs_fcst_qty",&lt;/P&gt;&lt;P&gt;"fcs_part",&lt;/P&gt;&lt;P&gt;"fcs_year"&lt;/P&gt;&lt;P&gt;&lt;B&gt;FROM&lt;/B&gt; PUB."fcs_sum";&lt;/P&gt;&lt;P&gt;&lt;B&gt;Join&lt;/B&gt; (&lt;I&gt;Inventory&lt;/I&gt;)&lt;/P&gt;&lt;P&gt;&lt;B&gt;Load&lt;/B&gt; Part,&lt;/P&gt;&lt;P&gt;Year,&lt;/P&gt;&lt;P&gt;Year&amp;amp;'.'&amp;amp;num(iterno(),'00') &lt;B&gt;as&lt;/B&gt; YearWeek,&lt;/P&gt;&lt;P&gt;Subfield(Qty,';',Iterno()) &lt;B&gt;as&lt;/B&gt; Qty,&lt;/P&gt;&lt;P&gt;Iterno() &lt;B&gt;as&lt;/B&gt; Week&lt;/P&gt;&lt;P&gt;&lt;B&gt;Resident&lt;/B&gt; TempForecast&lt;/P&gt;&lt;P&gt;&lt;B&gt;WHILE&lt;/B&gt; iterno()&amp;lt;substringcount(Qty,';')+2;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Drop&lt;/B&gt; &lt;B&gt;Table&lt;/B&gt; &lt;I&gt;TempForecast;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;LEFT&lt;/B&gt; &lt;B&gt;JOIN&lt;/B&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;LOAD&lt;/P&gt;&lt;P&gt;Part&lt;/P&gt;&lt;P&gt;,"Week"&lt;/P&gt;&lt;P&gt;,rangemax(0,if("Week"=1,ceil(rand()*100),peek("Available")-previous("Qty"))) &lt;B&gt;as&lt;/B&gt; "Available"&lt;/P&gt;&lt;P&gt;&lt;B&gt;RESIDENT&lt;/B&gt; [Inventory]&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P style="font-style: italic"&gt;[Weeks of Stock]:&lt;/P&gt;&lt;P style="font-weight: bold"&gt;LOAD&lt;/P&gt;&lt;P&gt;Part&lt;/P&gt;&lt;P&gt;,min("Week") - 1 &lt;B&gt;as&lt;/B&gt; "Weeks Available"&lt;/P&gt;&lt;P&gt;&lt;B&gt;RESIDENT&lt;/B&gt; [Inventory]&lt;/P&gt;&lt;P&gt;&lt;B&gt;WHERE&lt;/B&gt; "Available" &amp;lt;= 0&lt;/P&gt;&lt;P&gt;&lt;B&gt;GROUP&lt;/B&gt; &lt;B&gt;BY&lt;/B&gt; Part&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're help will be muchly appreciated!!!&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Dayna Litherland&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2009 15:55:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Countdown-of-stock/m-p/161663#M35466</guid>
      <dc:creator>Dayna</dc:creator>
      <dc:date>2009-08-20T15:55:30Z</dc:date>
    </item>
  </channel>
</rss>

