Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using Variables in Function to Set Chart Title

Hi Folks,

I'm trying to set my chart title name by using a vbscript function

Function GetMyChartName()

GetMyChartName = "Bob"

End Function

In the Chart->Properties->Window Title I have

= GetMyChartName

This works and my chart title is Bob.

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:

Function GetMyChartName()

dim var_value

var_value = ActiveDocument.Variables("PresetVariable").GetContent.string

GetMyChartName = var_value

end function

This does not work and it's the ActiveDocument line that is causing it to fail.

Can anyone shed any light on why?

Thanks,

Jes

2 Replies
Not applicable
Author

Hi Jes:

If all you need to do is to dynamically set the chart name, you don't need to go through all the vbscript hassle.

Just use something like this --> http://www.learnqlickview.com/how-to-display-dynamic-titles-in-qlikview/

Hope this helps!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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.

As an alternative, can you just reference the variable in the Caption expression like:

=PresetVariable

-Rob