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

Loading data based on user selection

Hi all,

i have a qlikview file with 2 tables, CustomerGroups and Customers,

since customers data are very large, i want the user should select a group from the CustomersGroups table,

and then the reload will import only for the customers for the selected group.

1. i imported the 2 tables with different column names for the GroupCode in order relationships should not created

2. i have a list box bounded to the groupcode field and a variable refering to it: =ONLY(GroupCode)

3. on load script:



select

when reloading data OCRD doesnt return any data, it looks like the variable doesnt contain the selection on this stage.

any ideas,

thanks

shlomo

;

* from OCRG;

SELECT

CardName FROM OCRD where GroupCode='$(a)';



6 Replies
vgutkovsky
Master II
Master II

Shlomo,

The problem is that you can't access a variable defined in that way during script execution. In the QV Help file, look up the Input() function which you might find helpful.

Otherwise, you could write out the variable to a text file when a user presses a button. The button press would write out to a text file and trigger a reload. The script would then use this text file as an "include" file.

Regards,

pover
Partner - Master
Partner - Master

You can use a variable in the script if it is a value and not an expression. My co-worker Ivan Cruz has another method that I'm going to ask him about tomorrow, but you can as do a macro that populates the variable with the value of a listbox so that you can then use it in the script. Here's an example:


sub make_list
'========== Copia periodo(s) seleccionado(s) a variable =================
'vFieldVariableList is defined previously as a document variable
set v = ActiveDocument.Variables("vFieldVariableList")
set mySelections =ActiveDocument.fields("Field").GetSelectedValues
vTemp = chr(39) & mySelections.Item(0).text & chr(39)
for i = 1 to mySelections.Count - 1
vTemp = vTemp & chr(44) & chr(39) & mySelections.Item(i).text &chr(39)
next
v.SetContent vTemp,true


end sub

sub clear_list
set v = ActiveDocument.Variables("vFieldVariableList")
v.SetContent "",true

end sub

You can run this macro with a button or with a trigger every time the user selects a value in the customer group list.

Regards.

Not applicable
Author

Hi,

thanks for your replies

shlomo

Anonymous
Not applicable
Author

Shlomo,
It works if you assign variable value in trigger instead of variable definiton. See attached test.

pover
Partner - Master
Partner - Master

Go with Michael's solution. Actions are always better than macros and in case you ever need to assign multiple values to the variable use the function =concat(chr(39)&Field1&chr(39),',') that is triggered OnSelect of Field1.

Regards.

Not applicable
Author

Hi,

thanks for your help.

shlomo