Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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)';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,
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.
Hi,
thanks for your replies
shlomo
Shlomo,
It works if you assign variable value in trigger instead of variable definiton. See attached test.
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.
Hi,
thanks for your help.
shlomo