Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

michaelcostner
New Contributor II

Select values in straight table chart using a macro

Hello,

I would like to create a macro that automatically selects values in a chart based on a variable's value.

I have a variable called Status that has a value of either A, B, C, or D. This variable is used as a dimension in a straight table chart.

When I run my macro, I would like to select lines in my chart where Status has a value of A or B. I have tried several different variations of the macro below, but it is not working.

sub Selects

arr1 = Array("A", "B")

ActiveDocument.Fields("Status").Select arr1

end sub

Seems like it should be fairly straightforward. Any thoughts about how I can get this macro to work?

Thanks!

Michael

2 Replies

Re: Select values in straight table chart using a macro

You need a loop to read the array-values:

sub Selects

arr1 = Array("A", "B")

for i = 0 to ubound(arr1) - 1

     ActiveDocument.Fields("Status").Select arr1(i)

next

end sub

But what is the reason for this routine?

- Marcus

michaelcostner
New Contributor II

Re: Select values in straight table chart using a macro

Thanks for the response Marcus, but that does not seem work either. The edit module window opens whenever I run the macro.

I am trying to add a few buttons to my Qlikview doc that allow me to quickly switch between different views of my chart, rather than selecting each field from a list or menu.

Is it possible to accomplish this without using an array?

Community Browser