<?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 Select field based on maxdate in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317834#M1200383</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks in advance for any replies!&lt;/P&gt;&lt;P&gt;Using =max(Date), we get the latest date from a table we have joined to&lt;/P&gt;&lt;P&gt;That works great&lt;/P&gt;&lt;P&gt;However, we also need to display in the next field, the associated value for that record, based on =max(Date)&lt;/P&gt;&lt;P&gt;Example data:&lt;BR /&gt;Main Table - Ref 123456&lt;/P&gt;&lt;P&gt;Linked table:&lt;BR /&gt;Ref 123456 - 21/03/2011 - red&lt;BR /&gt;Ref 123456 - 25/03/2011 - blue&lt;BR /&gt;Ref 123456 - 29/03/2011 - green (THEREFORE =max(Date))&lt;BR /&gt;&lt;BR /&gt;In the above example we would like to pull 29/03/2011 for =max(Date), and 'green' based on =max(Date) of 29/03/2011&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Apr 2011 15:14:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-04-04T15:14:37Z</dc:date>
    <item>
      <title>Select field based on maxdate</title>
      <link>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317834#M1200383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks in advance for any replies!&lt;/P&gt;&lt;P&gt;Using =max(Date), we get the latest date from a table we have joined to&lt;/P&gt;&lt;P&gt;That works great&lt;/P&gt;&lt;P&gt;However, we also need to display in the next field, the associated value for that record, based on =max(Date)&lt;/P&gt;&lt;P&gt;Example data:&lt;BR /&gt;Main Table - Ref 123456&lt;/P&gt;&lt;P&gt;Linked table:&lt;BR /&gt;Ref 123456 - 21/03/2011 - red&lt;BR /&gt;Ref 123456 - 25/03/2011 - blue&lt;BR /&gt;Ref 123456 - 29/03/2011 - green (THEREFORE =max(Date))&lt;BR /&gt;&lt;BR /&gt;In the above example we would like to pull 29/03/2011 for =max(Date), and 'green' based on =max(Date) of 29/03/2011&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2011 15:14:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317834#M1200383</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-04T15:14:37Z</dc:date>
    </item>
    <item>
      <title>Re. :Select field based on maxdate</title>
      <link>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317835#M1200384</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 have to do something like that :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;=firstSortedValue(Color,-Date)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Hope that helps you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2011 15:19:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317835#M1200384</guid>
      <dc:creator>martin59</dc:creator>
      <dc:date>2011-04-04T15:19:35Z</dc:date>
    </item>
    <item>
      <title>Select field based on maxdate</title>
      <link>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317836#M1200385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may treat this in the script, like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;&lt;BR /&gt;load&lt;BR /&gt; DATE,&lt;BR /&gt; if(DATE=DATE_MAX,'green','blue') AS COLOR,&lt;BR /&gt; A,&lt;BR /&gt; B,&lt;BR /&gt; C&lt;BR /&gt;;&lt;BR /&gt;load&lt;BR /&gt; DATE,&lt;BR /&gt; max(DATE) as DATE_MAX,&lt;BR /&gt; A,&lt;BR /&gt; B,&lt;BR /&gt; C&lt;BR /&gt;FROM TABLE1&lt;BR /&gt;GROUP BY A,B,C&lt;BR /&gt;;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2011 15:29:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317836#M1200385</guid>
      <dc:creator>fernandotoledo</dc:creator>
      <dc:date>2011-04-04T15:29:35Z</dc:date>
    </item>
    <item>
      <title>Re. :Select field based on maxdate</title>
      <link>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317837#M1200386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked perfectly - thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2011 15:46:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317837#M1200386</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-04T15:46:21Z</dc:date>
    </item>
    <item>
      <title>Re. :Select field based on maxdate</title>
      <link>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317838#M1200387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Firstsortorder returns null, if his max(Date) is on more than one record, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure I read your data model correct, but they are in same table right? How about using FieldValue and FieldIndex to pull it out: FieldValue('Colour',FieldIndex('Date',max(Date))). Maybe with some sorting during load, if more than one record can hold the max(Date).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2011 15:52:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Select-field-based-on-maxdate/m-p/317838#M1200387</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-04T15:52:29Z</dc:date>
    </item>
  </channel>
</rss>

