<?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 Finding matching dimension for min value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238514#M89369</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need a little help with this expression. (Example QVW attached). For two tables:&lt;/P&gt;&lt;P&gt;ShipmentId, Destination, Carrier&lt;BR /&gt;1, D1, B&lt;/P&gt;&lt;P&gt;Destination, Carrier, Rate&lt;BR /&gt;D1, A, 2000&lt;BR /&gt;D1, B, 2500&lt;BR /&gt;D1, C, 1500&lt;BR /&gt;D1, D, 1800&lt;/P&gt;&lt;P&gt;In a chart, I can find the lowest Rate for a ShipmentId with:&lt;/P&gt;&lt;P&gt;=aggr(min(Rate), Destination)&lt;/P&gt;&lt;P&gt;In the same chart, how can I display the Carrier associated with that lowest Rate? Somthing like:&lt;/P&gt;&lt;P&gt;&lt;!--StartFragment--&gt;&lt;/P&gt;&lt;TABLE bgcolor="white" border="1" bordercolor="white" cellpadding="0" cellspacing="0" style="FONT-SIZE: 9pt"&gt;&lt;TBODY&gt;&lt;TR align="left" bgcolor="#F5F5F5"&gt;&lt;TH&gt;&lt;B&gt;ShipmentId&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Destination&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Carrier&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Rate&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Best Rate&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Best Carrier&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR align="left" bgcolor="white"&gt;&lt;TD align="center" bgcolor="white"&gt;1&lt;/TD&gt;&lt;TD bgcolor="white"&gt;D1&lt;/TD&gt;&lt;TD bgcolor="white"&gt;B&lt;/TD&gt;&lt;TD align="right" bgcolor="white"&gt;2500&lt;/TD&gt;&lt;TD align="right" bgcolor="white"&gt;1500&lt;/TD&gt;&lt;TD bgcolor="white"&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Mar 2011 20:32:43 GMT</pubDate>
    <dc:creator>rwunderlich</dc:creator>
    <dc:date>2011-03-03T20:32:43Z</dc:date>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238514#M89369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need a little help with this expression. (Example QVW attached). For two tables:&lt;/P&gt;&lt;P&gt;ShipmentId, Destination, Carrier&lt;BR /&gt;1, D1, B&lt;/P&gt;&lt;P&gt;Destination, Carrier, Rate&lt;BR /&gt;D1, A, 2000&lt;BR /&gt;D1, B, 2500&lt;BR /&gt;D1, C, 1500&lt;BR /&gt;D1, D, 1800&lt;/P&gt;&lt;P&gt;In a chart, I can find the lowest Rate for a ShipmentId with:&lt;/P&gt;&lt;P&gt;=aggr(min(Rate), Destination)&lt;/P&gt;&lt;P&gt;In the same chart, how can I display the Carrier associated with that lowest Rate? Somthing like:&lt;/P&gt;&lt;P&gt;&lt;!--StartFragment--&gt;&lt;/P&gt;&lt;TABLE bgcolor="white" border="1" bordercolor="white" cellpadding="0" cellspacing="0" style="FONT-SIZE: 9pt"&gt;&lt;TBODY&gt;&lt;TR align="left" bgcolor="#F5F5F5"&gt;&lt;TH&gt;&lt;B&gt;ShipmentId&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Destination&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Carrier&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Rate&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Best Rate&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;TH&gt;&lt;B&gt;Best Carrier&lt;/B&gt; &lt;B&gt;&lt;/B&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR align="left" bgcolor="white"&gt;&lt;TD align="center" bgcolor="white"&gt;1&lt;/TD&gt;&lt;TD bgcolor="white"&gt;D1&lt;/TD&gt;&lt;TD bgcolor="white"&gt;B&lt;/TD&gt;&lt;TD align="right" bgcolor="white"&gt;2500&lt;/TD&gt;&lt;TD align="right" bgcolor="white"&gt;1500&lt;/TD&gt;&lt;TD bgcolor="white"&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 20:32:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238514#M89369</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2011-03-03T20:32:43Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238515#M89370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how about&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only(total {&amp;lt;Rate={$(=Min(Rate))}&amp;gt;} Carrier)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 20:39:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238515#M89370</guid>
      <dc:creator />
      <dc:date>2011-03-03T20:39:01Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238516#M89371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rob,&lt;/P&gt;&lt;P&gt;I'd use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;FirstSortedValue(TOTAL Carrier, Rate)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 20:41:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238516#M89371</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-03-03T20:41:16Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238517#M89372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Miguel. That appears to the right track but it doesn't work when I add other destinations. Attached is an expanded example with a second destination. I figured I needed to add additional dimensions into the total but that didn't give the correct result either.&lt;/P&gt;&lt;P&gt;=FirstSortedValue(TOTAL &amp;lt;Destination, Carrier&amp;gt; Carrier, Rate)&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 21:27:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238517#M89372</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2011-03-03T21:27:55Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238518#M89373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob, I would do it in the script instead, since I can't figure out a way that works for more shipments or destinations. Hence I added the following code within the script:&lt;/P&gt;&lt;P&gt;BestRates:&lt;BR /&gt;Load Destination, firstsortedvalue(Carrier,Rate) as BestCarrier, min(Rate) as BestRate&lt;BR /&gt;resident Rate&lt;BR /&gt;group by Destination;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 21:33:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238518#M89373</guid>
      <dc:creator />
      <dc:date>2011-03-03T21:33:27Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238519#M89374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This appears to work:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(firstsortedvalue(Carrier,Rate),Destination)&lt;/P&gt;&lt;P&gt;Edit: On second thought, since multiple carriers can have the same rate, and firstsortedvalue() returns null in that case, I'm not happy with that expression. I'd rather have a list that I can concatenate. I could swear that either I've solved this or seen the solution before...&lt;/P&gt;&lt;P&gt;Edit: Found what I was looking for. Adapting for this situation, it looks like this does the trick, though maybe there's a simpler expression. I'm not seeing it, though.&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(concat(aggr(if(rank(-Rate,1,1)=1,Carrier),Destination,Carrier),','),Destination)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 21:47:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238519#M89374</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-03-03T21:47:37Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238520#M89375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ivan. I can't do it in the script because in the application I need to allow for selections.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 21:49:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238520#M89375</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2011-03-03T21:49:22Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238521#M89376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks John. That's just what I was looking for.&lt;/P&gt;&lt;P&gt;I addressed the multiple carrier problem by creating a "CarrierPreference" field of small values (0.1, 0.2, etc) and added them to the Rate in the function. The concept of a preference already existed in the real app.&lt;/P&gt;&lt;P&gt;=aggr(firstsortedvalue(Carrier,Rate+CarrierPreference),Destination)&lt;/P&gt;&lt;P&gt;The idea ported fine to the real application, which has several more dimensions. For the record, attached is the completed example qvw.&lt;/P&gt;&lt;P&gt;Thanks again to all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 23:44:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238521#M89376</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2011-03-03T23:44:58Z</dc:date>
    </item>
    <item>
      <title>Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238522#M89377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John, Rob, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is great stuff....&amp;nbsp; I utilized John's second method since I ran into the firstsortedvalue null issue John mentioned and got back - for all my cases.&amp;nbsp;&amp;nbsp; However, is there a way to use the second case where a concatenated list is generated and I can get only the max or min of the concatenated list?&amp;nbsp; I am trying to use this value in another computation and need a single value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your consideration and if you can respond to this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 20:45:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238522#M89377</guid>
      <dc:creator />
      <dc:date>2011-08-29T20:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238523#M89378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're getting all nulls, I'd guess either your example is different in some important way, or you've made some minor mistake while adapting the expression to your real example.&amp;nbsp; Either way, it would be difficult to diagnose without seeing your real example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get the max or min, just replace concat() with maxstring() or minstring(), and of course remove the second parameter of the concat().&amp;nbsp; This works fine in Rob's example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;aggr(minstring(aggr(if(rank(-Rate,1,1)=1,Carrier),Destination,Carrier)),Destination)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 22:37:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238523#M89378</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-29T22:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Finding matching dimension for min value</title>
      <link>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238524#M89379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks John…&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That’s a little simpler than computing it as I did.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 23:05:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Finding-matching-dimension-for-min-value/m-p/238524#M89379</guid>
      <dc:creator />
      <dc:date>2011-08-29T23:05:33Z</dc:date>
    </item>
  </channel>
</rss>

