Domanda

Hello kind helpful people,

I am having a major problem in Qlikview. I am just trying to create a button that can increment a variable by +1 each time it is clicked. I thought i could simply write an expression on a button click event but Qlikview is so different. I think it overcomplicates this matter by trying to be too simple. The only thing i can do is 'Set a variable' to a specific value in the button properties.

Does anyone know how to do this?

Many thanks

Eddy

È stato utile?

Soluzione 3

No that's the thing, as i mentioned in my original post all SET VARIABLE does is set a variable to a specific value that you have to specify but you cannot (as far as I know) set an expression that will increment the variable continiously by +1.

Anyway, I figured it out - and for anyone else whose stuck on the same issue:

I found a long winded way of doing it, although it works well.

1) Create your variable in Qlikview, mine is called 'vIncrement'

2) Set up a macro by going into button 'properties' > 'Add' > action type = 'External' > 'Run Macro'

3) Then name your macro and click on 'Edit Module'

4) Paste the following bit of vbScript:

Sub Increment 
   TheVal = ActiveDocument.Variables("vIncrement").getcontent.string 
   TheVal = TheVal + 1 
   ActiveDocument.Variables("vIncrement").SetContent TheVal, True 
End sub

5) Click OK and close

This should do the trick.

I actually figured this out in about 20 minutes and I'm a total Qlikview amatuer whose never had any formal training in it lol, but StackOverflow.com won't let me paste my own answer for atleast 10 hours because I'm new here - I cannot understand why?

Never knew about vbscripting Qlikview Macro's until 10 minutes before - not bad eh for an amatuer?

I have to admit there must be a simpler method than this...but atleast this method works.

Cheers

Eddy Jawed

Altri suggerimenti

You can do this like you originally tried with an expression in the button action... the key is to make sure you put the = in there so vCount (or whatever your variable is called) gets evaluated first.

enter image description here

I am unable to add a comment, but I wanted to make sure you knew that macros won't work on server, so if you are doing it just for you it should be fine, but if you have it run on a server it could cause problems.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top