<?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: Building a formula to get the right date in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339931#M839558</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have same in qlikview file. What was the issue?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Apr 2017 19:45:42 GMT</pubDate>
    <dc:creator>Anil_Babu_Samineni</dc:creator>
    <dc:date>2017-04-28T19:45:42Z</dc:date>
    <item>
      <title>Building a formula to get the right date</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339930#M839557</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 need your help in the following issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have loaded to QV the set of following data regarding stock movements:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Loaded Data.GIF" class="jive-image image-1" src="/legacyfs/online/161670_Loaded Data.GIF" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757; text-decoration: underline;"&gt;Product Code&lt;/SPAN&gt; – Code of stock item&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Incoming_Doc&lt;/SPAN&gt; – if value &amp;gt; 0, stock document used to enter new products into stock, if value &amp;lt; 0, stock document decreased with quantities and values leaving stock (for production)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Outgoing_Doc&lt;/SPAN&gt; – doc number used for outgoing products&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Date&lt;/SPAN&gt; – dates of stock movements&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Quantity&lt;/SPAN&gt; – kilograms/ metres etc of materials&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Value&lt;/SPAN&gt; – value of materials&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I would like to know for each Product_Code the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 12pt;"&gt;&lt;STRONG style="text-decoration: underline;"&gt;Oldest incoming&lt;/STRONG&gt;&lt;/SPAN&gt; date– the oldest date of still opened Incoming_Doc for given Product Code.&lt;/P&gt;&lt;P&gt;Incoming_Doc is still opened if its quantity (taking all outgoing moves) is still &amp;gt;0&lt;/P&gt;&lt;P&gt;Closed incoming_Doc --&amp;gt; the quantity = 0&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;PZ/OL 03950/2008 is a closed Incoming_Doc:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;IMG alt="closed Incom_doc.GIF" class="jive-image image-2" src="/legacyfs/online/161672_closed Incom_doc.GIF" style="height: 70px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; font-size: 12pt; text-decoration: underline;"&gt;&lt;SPAN style="color: #ff0000; text-decoration: underline;"&gt;Newest outgoing&lt;/SPAN&gt;&lt;/STRONG&gt; date – the newest date for the outgoing stock movement for given Product_Code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quantity and Value should show the totals for given Product_Code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so the table I am trying to build should look like that:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="table_I_aim_to_create.GIF" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/161673_table_I_aim_to_create.GIF" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no idea how to get the &lt;SPAN style="color: #ff0000;"&gt;red&lt;/SPAN&gt; dimensions. Could you please help me? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339930#M839557</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Building a formula to get the right date</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339931#M839558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have same in qlikview file. What was the issue?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Apr 2017 19:45:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339931#M839558</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2017-04-28T19:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Building a formula to get the right date</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339932#M839559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try adding these two expressions:&lt;/P&gt;&lt;P&gt;incomming: FirstSortedValue({&amp;lt;Incomming_Doc={"=sum(QUANTITY)&amp;gt;0"}&amp;gt;}Incomming_Doc,Date)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;outgoing: FirstSortedValue(Outgoing_Doc,-Date)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Apr 2017 13:22:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339932#M839559</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2017-04-30T13:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Building a formula to get the right date</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339933#M839560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;‌thanks Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I starter to doubt I get any answer. Now I am on holiday but when I come back in the middle of next weekend,I try and let you know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BRgds,&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Apr 2017 17:34:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339933#M839560</guid>
      <dc:creator />
      <dc:date>2017-04-30T17:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Building a formula to get the right date</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339934#M839561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function doest not work in a way I want ...yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Starting from &lt;STRONG&gt;newest outgoing date&lt;/STRONG&gt; - your formula: &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;FirstSortedValue(Outgoing_Doc,-Date), however:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;- I would like to get the "Date" as the outcome, and not the "Outgoing_Doc" (so, just replace Outgoing_Doc with Date ... BUT ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;- I would like to get this newest date for which the Outgoing_Doc exists for a given Product_Code. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;If I would leave the formula with the following syntax: &lt;EM&gt;&lt;STRONG&gt;=FirstSortedValue(distinct Date,-Date),&lt;/STRONG&gt;&lt;/EM&gt; then if &lt;STRONG&gt;yesterday&lt;/STRONG&gt; we entered into stock product "123", and &lt;STRONG&gt;a week ago&lt;/STRONG&gt; it was the last time product "123" left stock, I get &lt;STRONG&gt;yesterday&lt;/STRONG&gt;, while I want to get&lt;STRONG&gt; a week ago date&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Let's have this one sorted first before sorting out the Oldest Incomming. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2017 10:14:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339934#M839561</guid>
      <dc:creator />
      <dc:date>2017-05-03T10:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Building a formula to get the right date</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339935#M839562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Starting from &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;newest outgoing date&lt;/STRONG&gt; - your formula: &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px;"&gt;FirstSortedValue(Outgoing_Doc,-Date), however:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px;"&gt;- I would like to get the "Date" as the outcome, and not the "Outgoing_Doc" (so, just replace Outgoing_Doc with Date ... BUT ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px;"&gt;- I would like to get this newest date for which &lt;STRONG&gt;&lt;EM&gt;the Outgoing_Doc&lt;/EM&gt;&lt;/STRONG&gt; exists for a given Product_Code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What does "&lt;STRONG&gt;the&lt;/STRONG&gt; Outgoing_Doc" mean? Is that a specific value or just any value as long as it's not null? If the latter then try &lt;SPAN style="font-size: 10pt;"&gt;Max({&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Incomming_Doc={"=sum(QUANTITY)&amp;gt;0"}&lt;/SPAN&gt;, Outgoing_Doc={'*'}&amp;gt;}Date).&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2017 17:36:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339935#M839562</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2017-05-03T17:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Building a formula to get the right date</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339936#M839563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, &lt;/P&gt;&lt;P&gt;Outgoing_Document is a string. each stock out movement must have its unique outgoing doc number. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I experimented with FirstSortedValue, and the below formula gives me perfectly the dates I wanted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FirstSortedValue( {&amp;lt;Outgoing_doc= {"*"} &amp;gt;} &lt;SPAN style="font-size: 10pt;"&gt;distinct Date,-Date)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;thanks a lot Gysbert for your hint with FirstSortedValue - I did not know this function, and after some research, it does the job. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Brgds &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Robert&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 14:39:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-formula-to-get-the-right-date/m-p/1339936#M839563</guid>
      <dc:creator />
      <dc:date>2017-05-04T14:39:39Z</dc:date>
    </item>
  </channel>
</rss>

