Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

How to read values from an input field and add them to the current selection?

Hi all,

I have this problem:

I have a database with many fields,one of them is CUSTOMER  ( around 1000 rows).

I have a Excel file with 100 customers , I copy and paste all this customers in an input field.

And the question is :   How i can add this customers (from the input field) to the current selection?

Thanks

1 Solution

Accepted Solutions
masha-ecraft
Contributor

How to read values from an input field and add them to the current selection?

Hi,

Here is a macro I used for such task:

sub CustomerListOnChange

set doc = ActiveDocument
set obj = doc.Fields("CUSTOMER")
set input = ActiveDocument.Variables("CustomerList")

varArray = input.GetContent.String

'replace line breaks with commas
if trim(varArray) <> "" then

varArray = Replace(varArray,chr(10),",")
varArray = Replace(varArray,chr(13),",")

varValue = split(varArray,",")

'Get a list of values already included in the current selection

set varSelection = obj.GetSelectedValues
j = varSelection.Count

'Add values to the list of selected values
for i=lbound(varValue) to ubound(varValue)
if varValue(i) <> "" then
varSelection.Add
varSelection(j).Text = varValue(i)
varSelection(j).IsNumeric = False
j = j+1
end if
next

'Make a new selection with the extended value list
obj.SelectValues varSelection, false, true

end if

end sub


The macro should be attached to the CustomerList variable OnChange event. CustomerList variable should be linked to the input field in your application.


/Masha

4 Replies
Not applicable

How to read values from an input field and add them to the current selection?

I think i need a Macro but which one?

masha-ecraft
Contributor

How to read values from an input field and add them to the current selection?

Hi,

Here is a macro I used for such task:

sub CustomerListOnChange

set doc = ActiveDocument
set obj = doc.Fields("CUSTOMER")
set input = ActiveDocument.Variables("CustomerList")

varArray = input.GetContent.String

'replace line breaks with commas
if trim(varArray) <> "" then

varArray = Replace(varArray,chr(10),",")
varArray = Replace(varArray,chr(13),",")

varValue = split(varArray,",")

'Get a list of values already included in the current selection

set varSelection = obj.GetSelectedValues
j = varSelection.Count

'Add values to the list of selected values
for i=lbound(varValue) to ubound(varValue)
if varValue(i) <> "" then
varSelection.Add
varSelection(j).Text = varValue(i)
varSelection(j).IsNumeric = False
j = j+1
end if
next

'Make a new selection with the extended value list
obj.SelectValues varSelection, false, true

end if

end sub


The macro should be attached to the CustomerList variable OnChange event. CustomerList variable should be linked to the input field in your application.


/Masha

Not applicable

How to read values from an input field and add them to the current selection?

Thx Masha

Not applicable

Re: How to read values from an input field and add them to the current selection?

Could someone attach a qvw with this example working?

DA

Community Browser