Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to cycling variable value

Hi Qlikers,

i need a macro to change the variable value between two values (ex. 0 and 1).

I know that Qlik v11 has this option within the actions of the button.

This setting action fix the variable value as I want but I need to have the macro that make this job.

Thank you in advance!!!!

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Its working . am using Qlikview12. Nothing wrong with the VB script

View solution in original post

9 Replies
Anonymous
Not applicable
Author

Hi ,

You can change the value dynamically after few seconds,

Try this-

Create variable

=if(second(now())>20,'1',if(second(now())>40,'2','3'))

Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

=if(second(now())>40,'1',if(second(now())>20,'2','3'))

Not applicable
Author

I've seen many Qlikers that propose this solution by time but I need to change on my own by a button or an input box.

Have any other ideas?

Anonymous
Not applicable
Author

If  the link i provided to use by macro, doesnt help you, you can aswell,

Create variable vVar,

Create button and add action in it to set variable value as If($(vVar)=1,0,1). It will alter the value every time you click the button

Not applicable
Author

Unfortunately i have Qlik v8 and i can't upgrade it at this moment.

I've already done this action in Qlik v11 as you told me but now i have another Qlik version to manage.

I need have the macro that make this job.

Not applicable
Author

I'm trying this VBScript:

Sub DispName

          set Name1 = ActiveDocument.Variables("vName")

          GetUserName = Name1.GetContent.String

          if ( GetUserName = 0 ) then

                         tmpString = 1

          else

                         tmpString = 0

          end if

          Name1.SetContent tmpString , true

End Sub


I want to set vName on 0 if the actual vName value is 1.

Everytime i want to fix the opposite value by button.

I don't know what there is wrong in this code to change the vName value.

Anonymous
Not applicable
Author

Its working . am using Qlikview12. Nothing wrong with the VB script

Not applicable
Author

I've tried in Qlik v11 and it works fine but it doesn't work in Qlik v8 .

I think that is a problem of VBScript of Qlik v8.

Thank you anyway!!!