<?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 Re: Inventory first sorted value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Inventory-first-sorted-value/m-p/387083#M144508</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;You use only sku, store_num as dimensions to calculate firstsortedvalue() so the inv price status is discarded by the first expression, just add it:&lt;/P&gt;&lt;P&gt;=sum(aggr(FirstSortedValue({&amp;lt;inv_cal_dt={"&amp;lt;=$(EndDateLY)"} &amp;gt;} oh_qty, (-inv_cal_dt + (Rand()*.001))), sku, store_num, Inv_prc_status_cd))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To involve only 'R' statuses, try this:&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;Inv_prc_status_cd={"R"}&amp;gt;} aggr(FirstSortedValue({&amp;lt;inv_cal_dt={"&amp;lt;=$(EndDateLY)"} &amp;gt;} oh_qty, (-inv_cal_dt + (Rand()*.001))), sku, store_num, Inv_prc_status_cd))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Oct 2012 10:07:06 GMT</pubDate>
    <dc:creator>whiteline</dc:creator>
    <dc:date>2012-10-06T10:07:06Z</dc:date>
    <item>
      <title>Inventory first sorted value</title>
      <link>https://community.qlik.com/t5/QlikView/Inventory-first-sorted-value/m-p/387082#M144507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All, &lt;/P&gt;&lt;P&gt;I've been working with the below expression to capture inventory for an item at a point in time (end date LY is a variable). &lt;/P&gt;&lt;P&gt;one thing to note about the source table is that it inserts a new row when there is a OH change. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;FirstSortedValue&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;inv_cal_dt&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;"&amp;lt;=$(EndDateLY)"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;} &amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;oh_qty&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;, (-&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;inv_cal_dt&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt; + (&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;Rand&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;()*.001))), &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;sku&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;store_num&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the expression has been working beautifully until we introduced inventory price status. Below is an example of inventory data for an item and store. &lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" height="123" style="width: 337px; height: 121px; border: #000000 1px solid;" width="335"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;inv price status&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;inv_cal_dt&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;oh_qty&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;9/29/2011&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;2/20/2011&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;R&lt;/TD&gt;&lt;TD&gt;2/13/2011&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;R&lt;/TD&gt;&lt;TD&gt;2/10/2011&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when using end date LY of 9/10/2011, the straight table returns 1 unit, but displays the inv cal date of 9/29/11. i woulld have expected to see 2/20/2011. Any help on where is the disconnect?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also (and more importantly), I would like to enhance the expression to include inv price status. For example, as of the variable date, display the OH only if the status in that row is R.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I’ve tried these, but they don’t do exactly what I need. They both display the 1 oh_qty with different inv cal dates and price status.&lt;/P&gt;&lt;P&gt;I would have expected to see nothing because even though there is 1 unit as of 9/10/2011 the price status is not R.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;Inv_prc_status_cd&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;='R',&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;FirstSortedValue&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;inv_cal_dt&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;"&amp;lt;=$(EndDateLY)"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;} &amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;oh_qty&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;, (-&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;inv_cal_dt&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt; + (&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;Rand&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;()*.001))), &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;sku&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;store_num&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;))) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;FirstSortedValue&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;inv_cal_dt&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;"&amp;lt;=$(EndDateLY)"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;}, &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;Inv_prc_status_cd&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;={'R'} &amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;oh_qty&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;, (-&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;inv_cal_dt&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt; + (&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: blue; font-size: 9pt;"&gt;Rand&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;()*.001))), &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;sku&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: maroon; font-size: 9pt;"&gt;store_num&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;Please help,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;"&gt;Sara&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2012 14:52:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inventory-first-sorted-value/m-p/387082#M144507</guid>
      <dc:creator />
      <dc:date>2012-10-05T14:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Inventory first sorted value</title>
      <link>https://community.qlik.com/t5/QlikView/Inventory-first-sorted-value/m-p/387083#M144508</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;You use only sku, store_num as dimensions to calculate firstsortedvalue() so the inv price status is discarded by the first expression, just add it:&lt;/P&gt;&lt;P&gt;=sum(aggr(FirstSortedValue({&amp;lt;inv_cal_dt={"&amp;lt;=$(EndDateLY)"} &amp;gt;} oh_qty, (-inv_cal_dt + (Rand()*.001))), sku, store_num, Inv_prc_status_cd))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To involve only 'R' statuses, try this:&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;Inv_prc_status_cd={"R"}&amp;gt;} aggr(FirstSortedValue({&amp;lt;inv_cal_dt={"&amp;lt;=$(EndDateLY)"} &amp;gt;} oh_qty, (-inv_cal_dt + (Rand()*.001))), sku, store_num, Inv_prc_status_cd))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Oct 2012 10:07:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inventory-first-sorted-value/m-p/387083#M144508</guid>
      <dc:creator>whiteline</dc:creator>
      <dc:date>2012-10-06T10:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Inventory first sorted value</title>
      <link>https://community.qlik.com/t5/QlikView/Inventory-first-sorted-value/m-p/387084#M144509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that results in 2 rows on the report, see below. it should only display C because its the most current.&lt;/P&gt;&lt;P&gt;the second expression also did not work for me. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="WIDTH: 392px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" width="98"&gt;Inv_prc_status_cd&lt;/TD&gt;&lt;TD class="xl66" style="border-left: medium none;" width="98"&gt;inv_cal_dt&lt;/TD&gt;&lt;TD class="xl67" width="98"&gt;sum(aggr(FirstSortedValue({&amp;lt;inv_cal_dt={"&amp;lt;=9/10/2011"} &amp;gt;} oh_qty, (-inv_cal_dt + (Rand()*.001))), sku, store_num, Inv_prc_status_cd))&lt;/TD&gt;&lt;TD class="xl67" style="border-left: medium none;" width="98"&gt;sum(&lt;BR /&gt;{&amp;lt;Inv_prc_status_cd={'R'} &amp;gt;} &lt;BR /&gt;aggr(FirstSortedValue({&amp;lt;inv_cal_dt={"&amp;lt;=9/10/2011"} &amp;gt;} oh_qty, (-inv_cal_dt + (Rand()*.001))), sku, store_num, Inv_prc_status_cd))&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="17" style="border-top: medium none;"&gt;C&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-left: medium none; border-top: medium none;"&gt;2/20/2011&lt;/TD&gt;&lt;TD class="xl67" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-left: medium none; border-top: medium none;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="17" style="border-top: medium none;"&gt;R&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-left: medium none; border-top: medium none;"&gt;10/7/2010&lt;/TD&gt;&lt;TD class="xl67" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;TD class="xl67" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="17" style="border-top: medium none;"&gt; &lt;/TD&gt;&lt;TD class="xl70" style="border-top: medium none;"&gt; &lt;/TD&gt;&lt;TD class="xl71" style="border-left: medium none; border-top: medium none;"&gt;2&lt;/TD&gt;&lt;TD class="xl71" style="border-left: medium none; border-top: medium none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 21:15:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inventory-first-sorted-value/m-p/387084#M144509</guid>
      <dc:creator />
      <dc:date>2012-10-08T21:15:58Z</dc:date>
    </item>
  </channel>
</rss>

