<?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: Use variable in QlikView script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315599#M711147</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will take some trial and error but should be doable.&amp;nbsp; Create a macro like the one below (off the top of my head so syntax will probably be off)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function passVar (strVar)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;passVar = ActiveDocument.Variables(chr(34) &amp;amp; strVar &amp;amp; chr(34).GetContent.String&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in your script use passVar(VariableName)&lt;/P&gt;&lt;P&gt;Might want to try something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vSomething = passVar(VariableName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've never done this before quite like this but I don't see why it wouldn't work.&amp;nbsp; I'm not 100% sure about the chr(34) part but I think it's fine (try it in a msg box I guess)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually you should just use like the statement below instead of ActiveDocument.Variables(chr(34) &amp;amp; strVar &amp;amp; chr(34).GetContent.String ...&lt;/P&gt;&lt;P&gt;ActiveDocument.GetFieldSelections("fieldname").text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or something like that I don't know the actual syntax off the top of my head so I'm almost certain it's wrong but if you look in the API guide it should be easy to figure out&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jun 2011 14:03:04 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-06-24T14:03:04Z</dc:date>
    <item>
      <title>Use variable in QlikView script</title>
      <link>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315594#M711138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use a variable in my script but it doesn't work.&lt;/P&gt;&lt;P&gt;First, I created a simple table with one field called 'site' which contains 3 values: value1, value2 and value3&lt;/P&gt;&lt;P&gt;After, I created a variable in my script and I want to have the selected value (value1 or value2 or value3) in it:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;LET myvariable = peek('site');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This expression doesn't work, 'myvariable' don't contains a correct value : &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;SQL SELECT champ FROM $(myvariable).table1 ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for your help ! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2011 13:38:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315594#M711138</guid>
      <dc:creator />
      <dc:date>2011-06-23T13:38:34Z</dc:date>
    </item>
    <item>
      <title>Use variable in QlikView script</title>
      <link>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315595#M711140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you selecting the 'value' to pass to the variable in the script or a front end table object?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Via the front-end you'll have to associate it with a variable that remains persistent after the reload has been initiated, conversley within the script you need to tell the variable which is the correct record eg:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vMyVariable = peek('MyData',-1,'site');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above would select the bottom record from the previously loaded table 'MyData'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps posting an example file would help matters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt - Visual Analytics Ltd&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2011 15:59:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315595#M711140</guid>
      <dc:creator>matt_crowther</dc:creator>
      <dc:date>2011-06-23T15:59:44Z</dc:date>
    </item>
    <item>
      <title>Use variable in QlikView script</title>
      <link>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315596#M711141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using peek outside of the table itself, you have to specify a table name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2011 21:20:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315596#M711141</guid>
      <dc:creator />
      <dc:date>2011-06-23T21:20:11Z</dc:date>
    </item>
    <item>
      <title>Use variable in QlikView script</title>
      <link>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315597#M711143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answers ! but I want the last selected value in my table and not the first or the last. &lt;/P&gt;&lt;P&gt;I want to do this : &lt;/P&gt;&lt;P&gt;1) I select a value in my table&lt;/P&gt;&lt;P&gt;2) ﻿The value goes to the script and the script is loaded &lt;/P&gt;&lt;P&gt;It's possible ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 08:55:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315597#M711143</guid>
      <dc:creator />
      <dc:date>2011-06-24T08:55:15Z</dc:date>
    </item>
    <item>
      <title>Use variable in QlikView script</title>
      <link>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315598#M711145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks for your answers ! but I want the last selected value in my table and not the first or the last. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to do this : &lt;/P&gt;&lt;P&gt;1) I select a value in my table&lt;/P&gt;&lt;P&gt;2) ﻿The value goes to the script and the script is loaded &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's possible ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 08:56:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315598#M711145</guid>
      <dc:creator />
      <dc:date>2011-06-24T08:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Use variable in QlikView script</title>
      <link>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315599#M711147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will take some trial and error but should be doable.&amp;nbsp; Create a macro like the one below (off the top of my head so syntax will probably be off)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function passVar (strVar)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;passVar = ActiveDocument.Variables(chr(34) &amp;amp; strVar &amp;amp; chr(34).GetContent.String&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in your script use passVar(VariableName)&lt;/P&gt;&lt;P&gt;Might want to try something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vSomething = passVar(VariableName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've never done this before quite like this but I don't see why it wouldn't work.&amp;nbsp; I'm not 100% sure about the chr(34) part but I think it's fine (try it in a msg box I guess)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually you should just use like the statement below instead of ActiveDocument.Variables(chr(34) &amp;amp; strVar &amp;amp; chr(34).GetContent.String ...&lt;/P&gt;&lt;P&gt;ActiveDocument.GetFieldSelections("fieldname").text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or something like that I don't know the actual syntax off the top of my head so I'm almost certain it's wrong but if you look in the API guide it should be easy to figure out&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 14:03:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Use-variable-in-QlikView-script/m-p/315599#M711147</guid>
      <dc:creator />
      <dc:date>2011-06-24T14:03:04Z</dc:date>
    </item>
  </channel>
</rss>

