Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Partner - Specialist II
Partner - Specialist II

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

end sub

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

end sub

View solution in original post

7 Replies
Anonymous
Not applicable
Author

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
Partner - Specialist III
Partner - Specialist III

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
Author

Would Bookmark be another alternative?

Not applicable
Author

Book mark and Where clause is not solve the problem.

I am looking for Macro to reduce the data .

jerrysvensson
Partner - Specialist II
Partner - Specialist II

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

end sub

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

end sub

Not applicable
Author

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,

marcus_sommer

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