Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

macro?


In macro tab

i want write a condition like

if (getfieldselections(product)=apple then 100,200)

so how to write this getfieldselections function in macro tab

if i write like is it work

whether i have to create variable for this need to use the variable in macro ?

if variable has to use then how to mention variable in edit module ( my variable name  is vprod)

pls tell me ?

8 Replies
sagarkharpude
Creator III
Creator III

Create the variable as follows

if (getfieldselections(product)='apple',100,200)

tresesco
MVP
MVP

Set v= ActiveDocument.GetVariable("VariableName")

Anonymous
Not applicable
Author

Hi tresesco,

i want write condition like getfieldselection(product)=apple

then

100

else

200

like this in script

how to write that condotion in macro tab

else

i created a variable

vp=getfieldselections(product)=apple

now i want use vp variable in  Macro script with if condition means like

if  vp then 100

else

200

pls tell me to write the script here

tresesco
MVP
MVP

Create the variable in the qv app and call it from macro code following the way I showed above.

Anonymous
Not applicable
Author

like above my variable is vp

but i want use it in if condition

tresesco
MVP
MVP

Try like:

Set v= ActiveDocument.GetVariable("vp")

If v=100 Then                                                      //corrected variable name

          ....do this

else

          ... do that   

Note: Corrected

Anonymous
Not applicable
Author

If you want to have multiple  value to be selected in Product field and want to identify if selection 'apple' is one of the product selected and then give out 100 as out put then you can use

Let vp= if(SubStringCount(Concat(product,'|'), 'apple'),100,200)

and in macro vb script you can get the variable value with below syntax

ActiveDocument.GetVariable("vp")

Anonymous
Not applicable
Author

First you need to create variable in your UI.

vProd= if(getfieldselections(product)=apple then 100,200)

you can write below code in macro to read the variable value assigned in UI . and use this values anywhere n Macro.

DIM vProd1

vProd1=ActiveDocument.GetVariable("vProd").GetContent.String

now you can use vProd1 for other calculation

Thanks

BKC