Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Qlikview Macro - Field Value into a Variable

Hi,

I have a requirement where I have

1. to get the Selected Field Value in a variable

2. Add a text to the variable

3. Store this content into a new variable

4. Clear all the field values selected.

Sub Var_Test

Set sel_val = ActiveDocument.Fields("Country").GetSelectedValues 
v= sel_val.Item(0).Text &", All Countries"
msgbox(v)
ActiveDocument.Variables("vTargetSpecies").SetContent v, true
ActiveDocument.Fields("Country").Clear

End Sub

The Macro is failing when being called. Can you please suggest me on this.

Thanks,

Venu

3 Replies
Not applicable
Author

Hi,

Your macro works. Make sure value is selected in the Listbox. The variable must be defined as well before macro is executed.

BR,

Kuba

Anil_Babu_Samineni

Might be problem in your script. Try this

v= sel_val.Item(0).Text & "All Countries"

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Not applicable
Author

Hey,

I tested his macro and it works just fine. It only fails in two situations:

1) Variable is not defined

2) No Country is selected.

BR,

Kuba