<?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: How do you retrieve field2 associated with max(field1) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626980#M1096942</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Will you explain exactly how this is interpreted and why it works?&amp;nbsp; Just curious... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 May 2014 14:41:26 GMT</pubDate>
    <dc:creator>triciagdaly</dc:creator>
    <dc:date>2014-05-08T14:41:26Z</dc:date>
    <item>
      <title>How do you retrieve field2 associated with max(field1)</title>
      <link>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626977#M1096939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an input box field with a date value, and deriving a maximum CP_EFFECTIVE_DATE where the CP_EFFECTIVE_DATE &amp;lt;= date from the input box.&amp;nbsp; The problem is I'm unable to retrieve field (CP_AMOUNT) that is associated with the max(CP_EFFECTIVE_DATE).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input box is vBenchmarkDate&lt;/P&gt;&lt;P&gt;In the Expression for CP_EFFECTIVE_DATE, I have:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;expression 1:&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; max({&amp;lt;CP_EFFECTIVE_DATE={"&amp;lt;=$(=date(vBenchmarkDate))"}&amp;gt;}CP_EFFECTIVE_DATE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The date in vBenchmarkDate is 10/1/2012, and it is correctly pulling the date 8/24/2012, which is the maximum CP_EFFECTIVE_DATE that is &amp;lt;= vBenchmarkDate of 10/1/2012.&amp;nbsp; in the table, this date has a CP_AMOUNT of .036 associated with it but am having problems retrieving this value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried setting an expression on CP_AMOUNT with:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;expression 2:&amp;nbsp; &lt;/STRONG&gt;&amp;nbsp; &lt;/EM&gt;firstsortedvalue(CP_AMOUNT,CP_EFFECTIVE_DATE), but it's returning the max(CP_AMOUNT) in the table, and not the one associated with the CP_EFFECTIVE_DATE from expression 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would greatly be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tricia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 14:15:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626977#M1096939</guid>
      <dc:creator>triciagdaly</dc:creator>
      <dc:date>2014-05-08T14:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do you retrieve field2 associated with max(field1)</title>
      <link>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626978#M1096940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=firstsortedvalue({&amp;lt;CP_EFFECTIVE_DATE={"&amp;lt;=$(=date(vBenchmarkDate))"}&amp;gt;} CP_AMOUNT, -CP_EFFECTIVE_DATE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note also the minus befor CP_EFFECTIVE_DATE to get the max.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 14:34:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626978#M1096940</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2014-05-08T14:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do you retrieve field2 associated with max(field1)</title>
      <link>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626979#M1096941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That works!!!&amp;nbsp; Thank you so much!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 14:39:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626979#M1096941</guid>
      <dc:creator>triciagdaly</dc:creator>
      <dc:date>2014-05-08T14:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do you retrieve field2 associated with max(field1)</title>
      <link>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626980#M1096942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Will you explain exactly how this is interpreted and why it works?&amp;nbsp; Just curious... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 14:41:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626980#M1096942</guid>
      <dc:creator>triciagdaly</dc:creator>
      <dc:date>2014-05-08T14:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do you retrieve field2 associated with max(field1)</title>
      <link>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626981#M1096943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider having a table in your data model with two fields, CP_AMOUNT and CP_EFFECTIVE_DATE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression above will filter your records using the set expression (filtering CP_EFFECTIVE_DATE before vBenchmarkDate), then the function will sort the remaining records based on the second argument &lt;EM&gt;ascending &lt;/EM&gt;and return the value of first argument's expression (field CP_AMOUNT) for the first sorted record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't use a minus before CP_EFFECTIVE, you will get CP_AMOUNT for the smallest CP_EFFECTIVE, but for the largest when using a minus.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just create a small table on paper and simulate to see what I mean.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 14:56:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-do-you-retrieve-field2-associated-with-max-field1/m-p/626981#M1096943</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2014-05-08T14:56:48Z</dc:date>
    </item>
  </channel>
</rss>

