Skip to main content
Announcements
Document boards are being consolidated, this board no longer allows NEW documents READ MORE

Example of Selecting Multiple Field Values

cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Example of Selecting Multiple Field Values

Attachments

In this post, I will demonstrate how to programmatically select multiple values in a field.

We know that manually, we can select multiple field values by pressing down on the Ctrl button and selecting the values in the field one at a time.


Screenshot of two values selected in the Year field:

pic1.png

There may be times when you have a requirement to pre-select multiple values programmatically, for example the current and previous months need to be selected when the document is opened.

Selecting multiple field values can be done through Actions.

The following steps illustrate how to add an Action to select 2013 and 2014 values in the Year field for a button (Actions can be added to other objects, such as the Sheet, Document, etc.):

  1. Go to the Properties of the button object
  2. Navigate to the Actions tab and add a new Action
  3. Choose the Selection for Action Type and choose Select in Field for Action
  4. In the Field textbox, enter the field name, in this example Year
  5. In the Search String textbox, enter the values to be selected, separated by the vertical bar | and enclosed in parentheses (), in this example (2013|2014)

The following screenshot illustrates the values 2013 and 2014 for the Year field:

pic2.png

When you press on the button, both 2013 and 2014 values should be selected together in the Year field.

Using Expressions:

The search string can also take expressions using the following syntax:

='(' & Expression1 & '|' & Expression2 & ')'

An example of using an expression to determine last and next month from today’s month:


='(' & Month(AddMonths(Date(Today()), -1)) & '|' & Month(AddMonths(Date(Today()), +1)) & ')'

An example of using variables for current and previous months:


='(' & $(vCurrentMonth) & '|' & $(vPreviousMonth) & ')'

Sample Application:

This post includes a sample application that illustrates a few options for selecting multiple values in a field.

Hope this post was helpful to you.

Labels (2)
Comments
Not applicable

This solution will not work if there are spaces or special characters in the field values.Double-qoutes around the values usually solve this issue.

However, in case the values are not controlled manually, one can create a parallel field which uses the numeric keys (or an AutoNumber function) on the field which you want to make the selections on. And then use the method provided above. That will work for sure!

datanibbler
Champion
Champion

That is really helpful. I was looking for something like that.

Thanks a lot!

0 Likes
Not applicable

This was very helpful. Thanks for taking the time to write it. I needed to search for "car" type words in a free text field using (*car *|*truck *| *auto *|*vehicle *) worked for me. I need need to expand the list but knowing the solution is very helpful.

0 Likes
kourosh_r
Contributor III
Contributor III

Very useful. Thank you

0 Likes
YoussefBelloum
Champion
Champion

it didn't work for me when i tried, because i have a field CURRENCY with values like this:

EUR

EUR (GPS)

I had to make this to make it works (in the fifth step)

5.     in the Search String textbox, enter the values to be selected, separated by the vertical bar | and enclosed in parentheses (), in this example (*EUR*|EUR (GPS))


THANK YOU



0 Likes
Chernov
Creator
Creator

( "EUR" | "EUR (GPS)" )

0 Likes
Anonymous
Not applicable

This solution may not work if there are spaces in between field values,use below expression for that case!!

in my case I wanted to select values like 'Level 0' ,'Level 1' ,'Level 2' from Level field ,

so if you want to select multiple values say Level 0 and Level 1 your o/p should be shown like this


("Level 0"|"Level 1")


to show o/p like use below expression

='('&' " '&Concat(distinct Level,'"|"')&' " '&')'

You can apply above expression as per your requirement ,and this will work smoothly.

cvalarcon
Contributor III
Contributor III

Hi Expert  in my case I need to put an interval in the Select in Field  between >=49000 and <50000 .

I put this (>=49000"|"<50000)  but is not working .

How can I do this ? 

Thanks

0 Likes
cvalarcon
Contributor III
Contributor III

Hi Expert I found the solution only  put "& "

(>=49000&<50000) 

Thanks any way

0 Likes
AndyA
Contributor II
Contributor II

Does this only work if you use "|" (pipe) as the separator in your data because I've tried it with my data (which doesn't have "|" in my data) and it does not work.  I don't think Qlikview uses | as a separator. 

0 Likes
Version history
Last update:
‎2014-07-05 11:11 AM
Updated by: