<?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: Find Maximum Value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886549#M309077</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ioannis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response - this is very helpful and confirms that I am going down the right route!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's still not working totally as it should be, and I think that's because I've missed out a step in the calculation. There may be multiple records per Group in each Container, so I think I first need to sum up the Units by Group and Container before doing the fisrtsortedvalue calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 May 2015 13:15:48 GMT</pubDate>
    <dc:creator>danielle_v</dc:creator>
    <dc:date>2015-05-19T13:15:48Z</dc:date>
    <item>
      <title>Find Maximum Value</title>
      <link>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886547#M309075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my data there is a field called Container. Each container will have one or more Groups against it, and I am trying to create a new field in the script (I will call this Group2) which gives me the name of the Group with the greatest number of units, by container.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below table gives an example of how my data looks;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="224" style="border: 1px solid rgb(0, 0, 0); border-image: none; width: 376px; height: 220px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Container&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Group&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Units&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Clothing&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Home&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;500&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Clothing&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;1,000&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Accessories&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Home&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;General&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;Accessories&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;5,000&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;Clothing&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;10,000&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And this is what I would want the Group2 field to show, based on the above examples;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" style="border: 1px solid rgb(0, 0, 0); border-image: none; width: 229px; height: 103px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Clothing&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;Clothing&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Home&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;&lt;STRONG&gt;Clothing&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt; So where there is more than one Group per Container, I need the Group2 field to show the Group with the greatest number of Units.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried various things using group by, firstsortedvalue and aggr, but can't get this to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 10:50:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886547#M309075</guid>
      <dc:creator>danielle_v</dc:creator>
      <dc:date>2015-05-19T10:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find Maximum Value</title>
      <link>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886548#M309076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;firstsortedvalue is the function you need to use :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;firstsortedvalue(Group, Units) as FieldName&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;group by Container&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Returns the first value of &lt;SPAN class="italic;"&gt;expression&lt;/SPAN&gt; sorted by corresponding &lt;SPAN class="italic;"&gt;sort-weight&lt;/SPAN&gt; when &lt;SPAN class="italic;"&gt;expression&lt;/SPAN&gt; is iterated over a number of records as defined by a &lt;SPAN class="Bold"&gt;group by&lt;/SPAN&gt; clause. &lt;SPAN class="italic;"&gt;Sort-weight&lt;/SPAN&gt; should return a numeric value where the lowest value will render the corresponding value of &lt;SPAN class="italic;"&gt;expression&lt;/SPAN&gt; to be sorted first. By preceding the &lt;SPAN class="italic;"&gt;sort-value&lt;/SPAN&gt; expression with a minus sign, the function will return the last value instead. If more than one value of expression share the same lowest &lt;SPAN class="italic;"&gt;sort-order&lt;/SPAN&gt;, the function will return NULL. By stating an &lt;SPAN class="italic;"&gt;n&lt;/SPAN&gt; larger than 1, the nth value in order will be returned. If the word &lt;SPAN class="Bold"&gt;distinct&lt;/SPAN&gt; occurs before the &lt;SPAN class="italic;"&gt;expression&lt;/SPAN&gt;, all duplicates will be disregarded. &lt;/P&gt;&lt;P class="example"&gt;Example:&lt;/P&gt;&lt;P class="Code"&gt;Load Customer, &lt;/P&gt;&lt;P class="Code"&gt;firstsortedvalue(PurchasedArticle, OrderDate) as FirstProductBought from abc.csv &lt;/P&gt;&lt;P class="Code"&gt;group by Customer;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 10:53:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886548#M309076</guid>
      <dc:creator>giakoum</dc:creator>
      <dc:date>2015-05-19T10:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find Maximum Value</title>
      <link>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886549#M309077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ioannis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response - this is very helpful and confirms that I am going down the right route!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's still not working totally as it should be, and I think that's because I've missed out a step in the calculation. There may be multiple records per Group in each Container, so I think I first need to sum up the Units by Group and Container before doing the fisrtsortedvalue calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 13:15:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886549#M309077</guid>
      <dc:creator>danielle_v</dc:creator>
      <dc:date>2015-05-19T13:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Find Maximum Value</title>
      <link>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886550#M309078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please close this discussion&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 14:38:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886550#M309078</guid>
      <dc:creator>giakoum</dc:creator>
      <dc:date>2015-05-19T14:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find Maximum Value</title>
      <link>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886551#M309079</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;one small correction, because you have to use the negative Units value as second parameter in the FirstSortedValue function to get the Group having the maximum Units value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table1:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LOAD * FROM [&lt;/SPAN&gt;&lt;A class="jive-link-thread-small" data-containerid="2051" data-containertype="14" data-objectid="164553" data-objecttype="1" href="https://community.qlik.com/thread/164553"&gt;https://community.qlik.com/thread/164553&lt;/A&gt;&lt;SPAN&gt;] (html, codepage is 1252, embedded labels, table is @1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table2:&lt;/P&gt;&lt;P&gt;LOAD Container,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstSortedValue(Group, &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG style="font-size: 14pt;"&gt;-&lt;/STRONG&gt;&lt;/SPAN&gt;Units) as Group2&lt;/P&gt;&lt;P&gt;Resident table1&lt;/P&gt;&lt;P&gt;Group By Container;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 15:53:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886551#M309079</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2015-05-19T15:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Find Maximum Value</title>
      <link>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886552#M309080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco - thanks for confirming!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had actually added in the negative, but forgot to mention in my earlier response &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 15:56:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Find-Maximum-Value/m-p/886552#M309080</guid>
      <dc:creator>danielle_v</dc:creator>
      <dc:date>2015-05-19T15:56:29Z</dc:date>
    </item>
  </channel>
</rss>

