Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Macro for selecting possible value

Hi!

In my macro I want to automaticaly select a possible value depending on antoher value (obviously) that i've selected manually.

Is this possbile?

Thanks!

//A.

Tags (1)
1 Solution

Accepted Solutions
gandalfgray
Valued Contributor

Macro for selecting possible value

Hi Annika

You can select all possible values in a field like this:

ActiveDocument.Fields("Month").SelectPossible

If you want to select matching a specific search value:

ActiveDocument.Fields("Month").Select "September"

(selects September)

ActiveDocument.Fields("Month").Select "J*"

(selects January, June, July)

ActiveDocument.Fields("Sales").Select ">1500"

(selects all Sales larger than 1500)

hope this helps!

16 Replies
montubhardwaj
Contributor III

Macro for selecting possible value

Why going for MAcros? you can easily achieve it through Triggers/Actions

gandalfgray
Valued Contributor

Macro for selecting possible value

Hi Annika

You can select all possible values in a field like this:

ActiveDocument.Fields("Month").SelectPossible

If you want to select matching a specific search value:

ActiveDocument.Fields("Month").Select "September"

(selects September)

ActiveDocument.Fields("Month").Select "J*"

(selects January, June, July)

ActiveDocument.Fields("Sales").Select ">1500"

(selects all Sales larger than 1500)

hope this helps!

Not applicable

Macro for selecting possible value

You're both right!

Thank you for your help!

=)

IAMDV
Honored Contributor II

Macro for selecting possible value

Have you considered using Indirect Set Analysis, which is more faster than macros & triggers.

• p( ) = Possible

• e( ) = Excluded

Example

sum(({<Year={$(=max(Year))},

Customer = p({<Year={$(=max(Year)-1)} Customer>}) Sales)

Cheers - DV

Not applicable

Re: Macro for selecting possible value

Hi GandalfGray,

       

                I have a similar kind of a requirement.Tried to iimplement whatever you have told but to no effect

   

                 Could you please elobarate on the Macro whatever you have mentioned.Should I take the

                 possible values into a variable.

Regards

Navin Gorapalli

gandalfgray
Valued Contributor

Re: Macro for selecting possible value

This is how a subroutine to select the possible values in the field "Month" could be written:

sub SelectPossibleInMonth()

ActiveDocument.Fields("Month").SelectPossible

end sub

then you obviously must call the macro whenever you want

You don't need any variables.

ActiveDocument.Fields("Month") specifies that its your field "Month" that the SelectPossible should be applied for.

Not applicable

Re: Macro for selecting possible value

Can you shed a little insight on how to accomplish this via and Action?  Thanks!

gandalfgray
Valued Contributor

Re: Macro for selecting possible value

Of course!

See the attached application, where possible colors are selected based on which fruit(s) are selected when the button is activated!

selectpossible.JPG

Not applicable

Re: Macro for selecting possible value

Ahh, I'm sorry - I thought there was a way to do it without a macro.    This will work for m, but I thought Macros were deprecated?

Community Browser