<?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 Passing value from variable for top select in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146719#M25235</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, that makes sense.&lt;/P&gt;&lt;P&gt;I was about to suggest an if...then, but it wouldn't be quite as dynamic. I'd take a little from your first macro and combine it with the if...then. Something like this should work:&lt;/P&gt;&lt;P&gt;Sub SelectTop10&lt;BR /&gt;'get value from list box and stored it to VShow&lt;BR /&gt;set val=ActiveDocument.Fields("SelectTypeOne").GetSelectedValues&lt;BR /&gt;Value= val.Item(0).Text&lt;BR /&gt;'ActiveDocument.Variables("VShow").SetContent value, true&lt;BR /&gt;' variable may not be needed&lt;/P&gt;&lt;P&gt;'Rank top 10 base product for sum of shoes&lt;/P&gt;&lt;P&gt;if Value = 'Product1' then&lt;BR /&gt; set f = ActiveDocument.GetField ("Product1")&lt;BR /&gt;else if Value = Product2' then&lt;BR /&gt; set f = ActiveDocument.GetField ("Product2")&lt;BR /&gt;' etc...&lt;BR /&gt;end if&lt;/P&gt;&lt;P&gt;f.TopSelect "sum(shoes)", 10&lt;/P&gt;&lt;P&gt;End sub&lt;/P&gt;&lt;P&gt;I just did a little more thinking on this. Do you have separate fields named Slippers, Sneaker, Dress Shoes, etc. (or Product1, Product2, etc)? Or are those values in a field?&lt;/P&gt;&lt;P&gt;This is what I am visualizing:&lt;/P&gt;&lt;P&gt;Product ProductTypes Shoes&lt;BR /&gt;Comfy Slips Slippers 5&lt;BR /&gt;Air Jordans Sneakers 7&lt;BR /&gt;Penny Loafers Dress Shoes 4&lt;BR /&gt;Converse ASs Sneakers 4&lt;/P&gt;&lt;P&gt;And then based on the selection, you would want the Top 10 Sneakers by number of shoes. I can't see where each product would be a separate field, which is what this macro would be for. (It's Friday, it wouldn't surprise me if I'm a little slow this morning! &lt;IMG alt="Big Smile" src="http://community.qlik.com/emoticons/emotion-2.gif" /&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jun 2009 22:55:20 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-06-12T22:55:20Z</dc:date>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146714#M25230</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;I have the following macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub SelectTop10&lt;BR /&gt;'get value from list box and stored it to VShow&lt;BR /&gt;set val=ActiveDocument.Fields("SelectTypeOne").GetSelectedValues&lt;BR /&gt;Value= val.Item(0).Text&lt;BR /&gt;ActiveDocument.Variables("VShow").SetContent value, true&lt;BR /&gt;&lt;BR /&gt;'Rank top 10 base product for sum of shoes&lt;BR /&gt;set f = ActiveDocument.GetField ("Product")&lt;BR /&gt;f.TopSelect "sum(shoes)", 10&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;End sub&lt;/P&gt;&lt;P&gt;I would like to substitue "Product" with the variable "VShow". Currently, Qlikview is throwing a Method can't be use for f.TopSelect. Am I missing something from here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for checking out my post! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 21:38:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146714#M25230</guid>
      <dc:creator />
      <dc:date>2009-06-12T21:38:08Z</dc:date>
    </item>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146715#M25231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does your field SelectTypeOne contain? Is that a list of fields?&lt;/P&gt;&lt;P&gt;You say you want to replace Product with VShow, so are you trying to use: set f = ActiveDocument.GetField(VShow) ? If so, you should try: set f = ActiveDocument.GetField($(VShow)).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 22:05:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146715#M25231</guid>
      <dc:creator />
      <dc:date>2009-06-12T22:05:36Z</dc:date>
    </item>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146716#M25232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The SelectTypeOne contains text (A,B and C). And yes, I am trying to replace hardcoded "Product" column with VShow which populates after user make a selection in SelecTypeOne.&lt;/P&gt;&lt;P&gt;I tried your example and received Invalid Character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for looking at this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 22:12:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146716#M25232</guid>
      <dc:creator />
      <dc:date>2009-06-12T22:12:23Z</dc:date>
    </item>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146717#M25233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, maybe you can't do a dollar sign expansion at that point.&lt;/P&gt;&lt;P&gt;From your macro, it looks like your setting VShow to be A, B or C. Then you're trying to reference that as a field name, but do you have a field named A, B or C? I'm still unsure about the connection between ShowOneValue and the fields in your application. I'd expect the values for ShowOneValue to be Product and/or other field names in your application. Maybe you could give a basic description of what you're trying to accomplish.&lt;/P&gt;&lt;P&gt;I set up a sample app to test your macro. If I try this: set f = ActiveDocument.GetField (VShow), I get an error, "Object Required: f" I get the same error if I try: set f = ActiveDocument.GetField ("$(VShow)"), so I must be doing something different, because you are getting different errors.&lt;/P&gt;&lt;P&gt;Also, in your macro, when you set Value, you capitalize the first letter. When you set the variable, you use value. Actually, I don't know if VB Script is case sensitive at that point. Have you used an Input Box or otherwise checked the value of VShow before you try to do the TopSelect?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 22:34:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146717#M25233</guid>
      <dc:creator />
      <dc:date>2009-06-12T22:34:20Z</dc:date>
    </item>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146718#M25234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are correct. Sorry I was trying to make a quick reply to your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the break down&lt;BR /&gt;&lt;BR /&gt;Listbox SelectTypeOne contains&lt;/P&gt;&lt;P&gt;Product1 (slippers)&lt;BR /&gt;Product2 (sneakers)&lt;BR /&gt;Product3 (dress shoes)&lt;BR /&gt;Shoes (# of pair sold)&lt;/P&gt;&lt;P&gt;I am currently store selected value from ListBox SelectTypeOne into a variable called VShow. I would like to use Vshow in&lt;/P&gt;&lt;P&gt;set f = ActiveDocument.GetField ("Product &amp;lt;--- replace with Vshow")&lt;BR /&gt;f.TopSelect "sum(shoes)", 10&lt;/P&gt;&lt;P&gt;So far it gives me error saying that "f" needs to be define.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other way that I can think of doing this is to do If then else statement. I just don't know how to write IF Statement that look for either selected field in a table or variable...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If ActiveDocument.Fields("SelectTypeOne").GetSelectedValueds ="Product1" then&lt;/P&gt;&lt;P&gt;set f = ActiveDocument.GetField ("Product1")&lt;BR /&gt;f.TopSelect "sum(shoes)", 10&lt;/P&gt;&lt;P&gt;End if&lt;/P&gt;&lt;P&gt;This statement doesn't work either.l&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 22:48:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146718#M25234</guid>
      <dc:creator />
      <dc:date>2009-06-12T22:48:41Z</dc:date>
    </item>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146719#M25235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, that makes sense.&lt;/P&gt;&lt;P&gt;I was about to suggest an if...then, but it wouldn't be quite as dynamic. I'd take a little from your first macro and combine it with the if...then. Something like this should work:&lt;/P&gt;&lt;P&gt;Sub SelectTop10&lt;BR /&gt;'get value from list box and stored it to VShow&lt;BR /&gt;set val=ActiveDocument.Fields("SelectTypeOne").GetSelectedValues&lt;BR /&gt;Value= val.Item(0).Text&lt;BR /&gt;'ActiveDocument.Variables("VShow").SetContent value, true&lt;BR /&gt;' variable may not be needed&lt;/P&gt;&lt;P&gt;'Rank top 10 base product for sum of shoes&lt;/P&gt;&lt;P&gt;if Value = 'Product1' then&lt;BR /&gt; set f = ActiveDocument.GetField ("Product1")&lt;BR /&gt;else if Value = Product2' then&lt;BR /&gt; set f = ActiveDocument.GetField ("Product2")&lt;BR /&gt;' etc...&lt;BR /&gt;end if&lt;/P&gt;&lt;P&gt;f.TopSelect "sum(shoes)", 10&lt;/P&gt;&lt;P&gt;End sub&lt;/P&gt;&lt;P&gt;I just did a little more thinking on this. Do you have separate fields named Slippers, Sneaker, Dress Shoes, etc. (or Product1, Product2, etc)? Or are those values in a field?&lt;/P&gt;&lt;P&gt;This is what I am visualizing:&lt;/P&gt;&lt;P&gt;Product ProductTypes Shoes&lt;BR /&gt;Comfy Slips Slippers 5&lt;BR /&gt;Air Jordans Sneakers 7&lt;BR /&gt;Penny Loafers Dress Shoes 4&lt;BR /&gt;Converse ASs Sneakers 4&lt;/P&gt;&lt;P&gt;And then based on the selection, you would want the Top 10 Sneakers by number of shoes. I can't see where each product would be a separate field, which is what this macro would be for. (It's Friday, it wouldn't surprise me if I'm a little slow this morning! &lt;IMG alt="Big Smile" src="http://community.qlik.com/emoticons/emotion-2.gif" /&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2009 22:55:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146719#M25235</guid>
      <dc:creator />
      <dc:date>2009-06-12T22:55:20Z</dc:date>
    </item>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146720#M25236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is exactly what I needed. Thank you so much for your help!!!!!!!!!!!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Jun 2009 00:16:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146720#M25236</guid>
      <dc:creator />
      <dc:date>2009-06-13T00:16:34Z</dc:date>
    </item>
    <item>
      <title>Passing value from variable for top select</title>
      <link>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146721#M25237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to help! &lt;IMG alt="Big Smile" src="http://community.qlik.com/emoticons/emotion-2.gif" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Jun 2009 01:12:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Passing-value-from-variable-for-top-select/m-p/146721#M25237</guid>
      <dc:creator />
      <dc:date>2009-06-13T01:12:22Z</dc:date>
    </item>
  </channel>
</rss>

