<?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 Selecting First X Values in Expression-Sorted Selection Box in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308733#M497289</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kaushik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have several line charts on a tab, one for return rates (returns divided by sales as percentages) by item, one for return rates by customer, and 3 straight tables that provide tabular totals for sales and returns. By default we want to see this data for the last 12 months for the top 12 products. I created the ltmSelector function for the last 12 months easily which I can fire via a button or on document load. I'm having difficulty with the top 12 items though. These same charts need to honor all selections so that they can change the date range and items/categories/etc. This is just a common view they want to default to or be able to quickly return to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Liron,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's a good idea and one I hadn't considered, but can I have multiple list boxes for the same field? Currently, I'm getting possible values with ActiveDocument.Fields("rMasterItemNo").GetPossibleValues. How would it know, or how would I tell it to use the top 12 list box versus the list box containing all items? Perhaps when you say Macro you're referring to something other than VB Script? I'll need to look into that...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Oct 2011 15:11:16 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-10-03T15:11:16Z</dc:date>
    <item>
      <title>Selecting First X Values in Expression-Sorted Selection Box</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308730#M497286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a button that selects the top 12 items (by sales). What I'm working with is a selection box that is sorted by an expression so that the top 12 items appear first (and the rest after that in descending order from top sales to no sales). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've created the following function in VB; similar to a function I have working to select the last 12 months in the calendar selection box, the big difference being the calendar selection box does not use an expression-sort:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub t12Selector&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set fld = ActiveDocument.Fields("rMasterItemNo")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set masterItems = fld.GetPossibleValues&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for i = 1 to 12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fld.ToggleSelect masterItems.Item(masterItems.count - i).Text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;next&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I execute the above function via a button however, the top 12 items do not get selected. The selection instead seems almost random. For reference, here is the sort expression from the selection box in question (I'm actually sorting on one of 7 sales values depending on another lag selection box):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=Sum( {$&amp;lt;rMasterItemNo=&amp;gt;} &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (rReturnLagOffset = '6', rSaleAmountLag6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,if (rReturnLagOffset = '5', rSaleAmountLag5&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,if (rReturnLagOffset = '4', rSaleAmountLag4 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,if (rReturnLagOffset = '3', rSaleAmountLag3 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,if (rReturnLagOffset = '2', rSaleAmountLag2 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,if (rReturnLagOffset = '1', rSaleAmountLag1 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,if (rReturnLagOffset = '0', rSaleAmountLag0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;))))))) &lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm assuming that GetPossibleValues is not returning a list of possible values in the same order that my expression sort is. What I want, is the actual top 12 items in that selection box to become selected. Does anyone know of any work-arounds, or of something I may be missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suggestions/thoughts much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 14:54:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308730#M497286</guid>
      <dc:creator />
      <dc:date>2011-10-03T14:54:10Z</dc:date>
    </item>
    <item>
      <title>Selecting First X Values in Expression-Sorted Selection Box</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308731#M497287</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;&amp;nbsp;&amp;nbsp; Can you please describe what are you trying to achieve. What output you expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kaushik Solanki&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 14:56:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308731#M497287</guid>
      <dc:creator>kaushiknsolanki</dc:creator>
      <dc:date>2011-10-03T14:56:27Z</dc:date>
    </item>
    <item>
      <title>Selecting First X Values in Expression-Sorted Selection Box</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308732#M497288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; hei &lt;/P&gt;&lt;P&gt;i would create a list box &lt;/P&gt;&lt;P&gt;with only the top 12 items &lt;/P&gt;&lt;P&gt;by using something like:&lt;/P&gt;&lt;P&gt;aggr(if(rank(Sum( {$&amp;lt;rMasterItemNo=&amp;gt;} &lt;/P&gt;&lt;P&gt; if (rReturnLagOffset = '6', rSaleAmountLag6&lt;/P&gt;&lt;P&gt; ,if (rReturnLagOffset = '5', rSaleAmountLag5 &lt;/P&gt;&lt;P&gt; ,if (rReturnLagOffset = '4', rSaleAmountLag4 &lt;/P&gt;&lt;P&gt; ,if (rReturnLagOffset = '3', rSaleAmountLag3 &lt;/P&gt;&lt;P&gt; ,if (rReturnLagOffset = '2', rSaleAmountLag2 &lt;/P&gt;&lt;P&gt; ,if (rReturnLagOffset = '1', rSaleAmountLag1 &lt;/P&gt;&lt;P&gt; ,if (rReturnLagOffset = '0', rSaleAmountLag0&lt;/P&gt;&lt;P&gt; ))))))) &lt;/P&gt;&lt;P&gt;))&amp;lt;=12,rMasterItemNo),rMasterItemNo)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then via macro select possible in the listbox&lt;/P&gt;&lt;P&gt;if you can post sample data &lt;/P&gt;&lt;P&gt;we can work it together&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 15:01:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308732#M497288</guid>
      <dc:creator>lironbaram</dc:creator>
      <dc:date>2011-10-03T15:01:40Z</dc:date>
    </item>
    <item>
      <title>Selecting First X Values in Expression-Sorted Selection Box</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308733#M497289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kaushik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have several line charts on a tab, one for return rates (returns divided by sales as percentages) by item, one for return rates by customer, and 3 straight tables that provide tabular totals for sales and returns. By default we want to see this data for the last 12 months for the top 12 products. I created the ltmSelector function for the last 12 months easily which I can fire via a button or on document load. I'm having difficulty with the top 12 items though. These same charts need to honor all selections so that they can change the date range and items/categories/etc. This is just a common view they want to default to or be able to quickly return to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Liron,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's a good idea and one I hadn't considered, but can I have multiple list boxes for the same field? Currently, I'm getting possible values with ActiveDocument.Fields("rMasterItemNo").GetPossibleValues. How would it know, or how would I tell it to use the top 12 list box versus the list box containing all items? Perhaps when you say Macro you're referring to something other than VB Script? I'll need to look into that...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 15:11:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308733#M497289</guid>
      <dc:creator />
      <dc:date>2011-10-03T15:11:16Z</dc:date>
    </item>
    <item>
      <title>Selecting First X Values in Expression-Sorted Selection Box</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308734#M497290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; after building the listbox&lt;/P&gt;&lt;P&gt;use this vb function&lt;/P&gt;&lt;P&gt;Sub t12Selector&lt;/P&gt;&lt;P&gt; set lb = ActiveDocument.GetSheetObject("LB01") - enter your list box ID&lt;BR /&gt;lb.SelectPossible&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 15:53:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308734#M497290</guid>
      <dc:creator>lironbaram</dc:creator>
      <dc:date>2011-10-03T15:53:48Z</dc:date>
    </item>
    <item>
      <title>Selecting First X Values in Expression-Sorted Selection Box</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308735#M497291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Iiron - your suggestions worked like a charm.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 15:59:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-First-X-Values-in-Expression-Sorted-Selection-Box/m-p/308735#M497291</guid>
      <dc:creator />
      <dc:date>2011-10-03T15:59:00Z</dc:date>
    </item>
  </channel>
</rss>

