Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
hobanwashburne
Creator
Creator

Resetting variables by Macro

I have a document that uses a lot of hide/show variables controlled by buttons to display different menus. Initially each button included an if statement such as:

if(vShowMenu01 = 1, 0,1) which would toggle the menu on/off each time the button is pressed.

as well as individual set variable actions to hide any other open menus

vShowMenu02 = 0

vShowMenu03 = 0

and so on...

I was looking for a better way to reset all other variables to 0 aside from the one I selected.

I did discover a macro on this forum ( http://community.qlik.com/thread/8567) which works to set everything 0.

However, when I assigned the actions for the button to first run the macro (clear/hide everything) and then set only the selected variable linked to that button to 1 it doesn't seem to recognize the second command (the variable remains set to 0).

2 Replies
Anonymous
Not applicable

You expect the button actions to be executed in a sequence - but it is not always the case when it comes to variables.
Can you add that second action into the same macro?  Looks like you'll need a separate macro for each button...

hobanwashburne
Creator
Creator
Author

Yes, because buttons have the promote/demote functionality I assumed that it would execute in sequence. I could add the second command within the macro, but as you stated, I would need a new macro for every button.

I have attached a test qwd that functions exactly as I would like, however each button contains as many as 8 separate commands (explicitly resetting each variable).

I would prefer each had two commands:

1- Show/Hide this

2-Hide everything else