Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

searching for multiple values in a field

Hi,

Please see attached example qvw file. If I click Test button with only one search word (for example Test), then the value is searched in the field MES correctly. However, when I want to search 2 values (for example, Test, Prod), then the search fails completely. In the attached example, search value is stored in a variable. The test button uses the action of Select in field (MES) with the  search string as ='*'&'$(vTest)'&'*'

Thanks for your help in resolving this multiple search issue

Thanks,

Deepak

1 Solution

Accepted Solutions
MVP
MVP

Re: searching for multiple values in a field

Right, the spaces seem to break the search string.

We can use another one, this will look kind of ugly (just copy it to a text box to see the search string uncovered):

Try this as search string in your button action:

='=wildmatch(MES,'&chr(39)&'*'&Replace('$(vTest)',',','*'&chr(39)&','&chr(39)&'*')&'*'&chr(39)&')'

7 Replies
MVP
MVP

Re: searching for multiple values in a field

Try using something like

='(*'& Replace('$(vTest)',',','*|*')&'*)'

as search expression in your button action.

Not applicable

Re: searching for multiple values in a field

I tried your solution but doesn't give what I was expecting. Please see attached file updated with your suggested expression.

When I search for Test, Prod I am expecting that all rows in the MES field to be selected now since 'Prod' is also in the last row (which is not selected).

Re: searching for multiple values in a field

Hi,

     See the attached file ..Don't give the space between test,prod ..

Hope it helps.

MVP
MVP

Re: searching for multiple values in a field

Right,

you can can remove one space after the comma automatically by using

='(*'& Replace(Replace('$(vTest)',', ',','),',','*|*')&'*)'

as search expression. Or maybe there is a better approach, but I can't look into that anymore today.

Not applicable

Re: searching for multiple values in a field

Mayil,Thanks for your suggestion to your remove the space and to swuehl to fix the space after the comma separator. I see the selection work perfectly now for multiple values as in your attachment Test.qvw. However, if the search word itself has space, the button action doesn't select the rows in MES field. Do you know how to handle if the space is in the search string itself like 'This is Test'? Further, is there a way to count the number of selected rows based on the search and display in a table? I am attaching the test file with the search string with a space when the button action doesn't work as expected.

Thanks both for your help.

MVP
MVP

Re: searching for multiple values in a field

Right, the spaces seem to break the search string.

We can use another one, this will look kind of ugly (just copy it to a text box to see the search string uncovered):

Try this as search string in your button action:

='=wildmatch(MES,'&chr(39)&'*'&Replace('$(vTest)',',','*'&chr(39)&','&chr(39)&'*')&'*'&chr(39)&')'

Not applicable

Re: searching for multiple values in a field

Wow...swuehl.  Thanks very much for your help. The code works perfectly. I will use this code for other fields as well to do similar search.

Best,

Deepak

Community Browser