Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Button Macro to Create Variable for Chart

Hi all, I am new to QlikView and have recently run into a problem. In my application, I have a chart similar to the example Google Maps chart that comes standard in QV 9. I would like to create a button that runs a macro to create a variable, which I am then able to call on in the chart expressions (in order to dynamically resize and recolor the dots based on the variable's value created by the button).

Any advice on how to go about this? I'm stumped.

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

I made an example. It's very simple

If you have any question feel free to ask.

Steve

View solution in original post

5 Replies
Not applicable
Author

Hello,

I don't understand your question very well, but if you just want to create a variable:

ActiveDocument.CreateVariable newVar

Set v = ActiveDocument.Variables(newVar)

v.setContent variableContent, true ' variableContent is the formula or expression for your new variable

Steve

Not applicable
Author

Hi Steve,

Thank you for the response and I apologize for being so confusing. It looks like this is going in the right direction but I still can't get it to work properly. What is "v" in the code? The variables I'm creating are not passing to the chart.

What I would like is this: 1. Button to create a variable called "newVar". Eventually, I want Button2 and Button3 to do the same thing via different formulas.

Button 1 will have:: newVar = sum(Sales) <-- Sales is a field in data table in the sheet, On click it sets and the chart is able to call it to dynamically change.

2. Separate sheet object, a Chart , set to reflect the value of the newVar.

Not applicable
Author

Hi,

I made an example. It's very simple

If you have any question feel free to ask.

Steve

Not applicable
Author

Thanks Steve! Solution was perfect.

I might have another question coming soon regarding a button to set a a Year to Date, Week to Date, and Last Week value in separate Year, Week, and Day list boxes but I'm going to give it some more thought first. I really appreciate your help.

~MIchael

Not applicable
Author

Hey Michael, I forgot to tell you that you have to verify if the variable is already created every time you press the button.

Steve