<?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 Using Variables in Function to Set Chart Title in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-Variables-in-Function-to-Set-Chart-Title/m-p/405617#M1238936</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to set my chart title name by using a vbscript function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function GetMyChartName()&lt;/P&gt;&lt;P&gt;GetMyChartName = "Bob"&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the Chart-&amp;gt;Properties-&amp;gt;Window Title I have&lt;/P&gt;&lt;P&gt;= GetMyChartName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works and my chart title is Bob.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I want to use a variable for the chart name (This has already been set up as PresetVariable in the Variable Overview screen) so instead my function would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function GetMyChartName()&lt;/P&gt;&lt;P&gt;dim var_value&lt;/P&gt;&lt;P&gt;var_value = ActiveDocument.Variables("PresetVariable").GetContent.string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GetMyChartName = var_value&lt;/P&gt;&lt;P&gt;end function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This does not work and it's the ActiveDocument line that is causing it to fail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone shed any light on why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Jan 2026 16:26:21 GMT</pubDate>
    <dc:creator />
    <dc:date>2026-01-26T16:26:21Z</dc:date>
    <item>
      <title>Using Variables in Function to Set Chart Title</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variables-in-Function-to-Set-Chart-Title/m-p/405617#M1238936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to set my chart title name by using a vbscript function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function GetMyChartName()&lt;/P&gt;&lt;P&gt;GetMyChartName = "Bob"&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the Chart-&amp;gt;Properties-&amp;gt;Window Title I have&lt;/P&gt;&lt;P&gt;= GetMyChartName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works and my chart title is Bob.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I want to use a variable for the chart name (This has already been set up as PresetVariable in the Variable Overview screen) so instead my function would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function GetMyChartName()&lt;/P&gt;&lt;P&gt;dim var_value&lt;/P&gt;&lt;P&gt;var_value = ActiveDocument.Variables("PresetVariable").GetContent.string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GetMyChartName = var_value&lt;/P&gt;&lt;P&gt;end function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This does not work and it's the ActiveDocument line that is causing it to fail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone shed any light on why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2026 16:26:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variables-in-Function-to-Set-Chart-Title/m-p/405617#M1238936</guid>
      <dc:creator />
      <dc:date>2026-01-26T16:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variables in Function to Set Chart Title</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variables-in-Function-to-Set-Chart-Title/m-p/405618#M1238939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all you need to do is to dynamically set the chart name, you don't need to go through all the vbscript hassle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just use something like this --&amp;gt; &lt;A href="http://www.learnqlickview.com/how-to-display-dynamic-titles-in-qlikview/" title="http://www.learnqlickview.com/how-to-display-dynamic-titles-in-qlikview/"&gt;http://www.learnqlickview.com/how-to-display-dynamic-titles-in-qlikview/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 14:58:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variables-in-Function-to-Set-Chart-Title/m-p/405618#M1238939</guid>
      <dc:creator />
      <dc:date>2015-01-02T14:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Variables in Function to Set Chart Title</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Variables-in-Function-to-Set-Chart-Title/m-p/405619#M1238941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure where the problem is, but as Ruben said, it's generally a bad idea to use macros in the UI, especially in expressions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an alternative, can you just reference the variable in the Caption expression like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;PresetVariable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 18:23:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Variables-in-Function-to-Set-Chart-Title/m-p/405619#M1238941</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2015-01-02T18:23:12Z</dc:date>
    </item>
  </channel>
</rss>

