Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Macro to select multiple values in the single field

I need to select multiple values in the single field

Example:

County

Japan

Singapore

Korea

China

Germany

USA

London

Brazil

Canada

I have to reduce the data and save the file only with Japan and China.

Another file will be USA,Canada.

Country is the field is linked with other tables. I would like to do this filtering only in the macro.

Thanks in Advance for your help.

1 Solution

Accepted Solutions
jerrysvensson
Valued Contributor II

Re: Macro to select multiple values in the single field

sub JapanChina
ActiveDocument.Fields("Country").Select "(Japan|China)"

end sub

sub USACanada
ActiveDocument.Fields("Country").Select "(USA|Canada)"

end sub

7 Replies
amarbogam
Contributor

Re: Macro to select multiple values in the single field

I am not very clear about why you want to use macro.

Are these statdard groupings or random?

Do you want to manually reduce the files or thru publisher?

Why not create another field for these groupings and use that field for the reducing of the files?

Gabriel
Valued Contributor II

Re: Macro to select multiple values in the single field

Hi,

First am not sure the explanation is clear.

If you wish to reduce and save a file containing information for a particular country, why not reduce in the script, just have a WHERE clause, i.e. WHERE Country ='Japan' OR Country ='China'...

Then STORE

INTO c\filelocation.

Also, if this is to prevent user from having access to other country's data then you can implement SECURITY read this blog by HIC, https://community.qlik.com/blogs/qlikviewdesignblog/2014/06/09/methods-for-data-reduction.

This are just general suggestion. If you can explain what you wish to achieve then someone from the community will give you more accurate suggestion.

Not applicable

Re: Macro to select multiple values in the single field

Would Bookmark be another alternative?

Not applicable

Re: Macro to select multiple values in the single field

Book mark and Where clause is not solve the problem.

I am looking for Macro to reduce the data .

jerrysvensson
Valued Contributor II

Re: Macro to select multiple values in the single field

sub JapanChina
ActiveDocument.Fields("Country").Select "(Japan|China)"

end sub

sub USACanada
ActiveDocument.Fields("Country").Select "(USA|Canada)"

end sub

Not applicable

Re: Macro to select multiple values in the single field

Hi Jerry what if one of the fields has a space? i am struggling with one:

sub JapanSouthAmerica
ActiveDocument.Fields("Country").Select "(Japan|South America)"

end sub



Thanks,

Re: Macro to select multiple values in the single field

An possibility would be to use multiple double-quotes like:

"(""Japan""|""South America"")"

or you used toggleselect:

ActiveDocument.Fields("Country").Select "Japan"

ActiveDocument.Fields("Country").ToggleSelect "South America"

- Marcus

Community Browser