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

Compound Search - demystified

cancel
Showing results for 
Search instead for 
Did you mean: 
swuehl
MVP
MVP

Compound Search - demystified

Last Update:

Sep 21, 2022 1:01:33 PM

Updated By:

Sue_Macaluso

Created date:

Jan 30, 2016 7:46:35 AM

Searching in field values is a powerful feature in QlikView (all this should also work in QlikSense, but I haven't tested everything). You can use searches for example in set analysis field modifier, select in field actions and not to forget filtering e.g. list boxes in the frontend.

Hence knowing the power of searches is vital to developers as well as end users.

Unfortunately (in terms of 'getting started with search'), there are several possible search modes, have a look at The Search String‌ to get an overview.

Text searches continues explaining. Some of the search modes are explained a bit more detailed: The Expression Search

And there are some things to consider we would hardly know without following Henric Cronström's ( hic‌ ) great design blog: Search - But what shall you find?

Not to forget, there is a nice cheat sheet: Qlik Sense Search Cheat Sheet,‌ covering some features, but not everything.

There is also of course some documentation in the HELP file as well as the reference manual, but not what I would call a comprehensive documentation of this essential product feature. Especially, there is few documentation about the so called 'compound search'.

So let us shed some light on

QlikView's Compound Search feature

First, let's create some sample data:

SAMPLE:

LOAD RecNo() as Number, Text

INLINE [

Text

Harry

Sally

Harry & Sally

New Hampshire

New York

Something new

UPPER

not upper

Al Bundy

Airport Newark

me

];

  • Triggering a compound search
    A compound search is triggered by enclosing the search filter in parentheses (...)
    The search itself will be performed over the values in the field's symbol table.


  • The most simple possible search filter is just inputting a value. In contrary to other search modes, the compound search will search for values that exactely match your search term.
    [Note: A case insensitive comparison will be performed, but according to some comments by Henric in above blog posts, this is considered a bug and may be fixed sometime in the future ]

    For example, (1) put into a Number field list box search bar will return only the exact match '1', not all values that contain '1' or start with '1'. Another example: Try upper compaired to (upper) in Text list box search bar.

Doc1.jpg

  • Wildcards
    You can use wildcards in a compound search, too. A question mark '?' is a placeholder for any single character, a star symbol '*' for any number of not defined characters.
    (?e) will return any value with two characters, second being an 'e'. (*e) will return any value that ends with an 'e'.

Doc2.jpg

  • Quoting
    If your values contain spaces, you need to quote the value: ("Something New") will find the value, (Something New) not.

  • Wildcard ^: Beginning of word
    If you quote your search string, you can also use the wildcard '^' to match your search term with beginning of words in your values
    (read further down why you need to quote here, even when there is no space contained):

Doc3.jpg

[Note: As Henric commented to one of his blog posts, there is no escape character to escape a wildcard, hence if you want to search for e.g. '?', you would need another search mode, e.g. advanced search using =index(FIELD,'?') ]

  • Combining searches using search operators:
    Now it's getting a little bit more advanced: If you want to create some more complex searches, you can combine two or more searches with search operators:
    • OR operator '|'
      Using this operator, your compound search will return values that match either the first or the second search, e.g.


Doc4.jpg

    • AND operator '&'
      Using this operator, your compound search will return values that match both first and second search, obviously, this does only make sense if you are using wildcards:

Doc5.jpg

    • Up to this point, all this can be found here in the forum, in Henric's design blog referenced above, in the comments to his blog, in the tech doc or in some other threads. But I hope this document will add something useful to all this already available, though distributed material. Introducing the AFAIK not really well-known
      XOR operator '^'
      Using this operator, your compound search will return values that match either the first or the second search, but not both:

Doc6.jpg

Another example for the XOR operator would be to find the complement of a search (for example search for *Sally*):

You could achieve this by selecting (Sally), then use the context menu to select excluded, but you can also use a single search: (* ^ *Sally*)

Doc9.jpg

[Agreed, the syntax would be easier if there was an operator for NOT or complement, but I haven't found it so far. If you know it, please drop a comment below.]

All these operators can be used to not only combine two, but many searches: (me|Harry|Sally)

This would be a good point to end this document. But there is something more I haven't read about so far:

  • Nesting compound searches
    You can nest a compound search into another compound search. Why you may want to do this?

    For example if you want to create a search like 'Return all values containing 'Harry', but exclude values where 'Sally' appears.
    Since to my limited knowledge, there is no 'NOT' or complement unary search operator, you can emulate this search using the existing three search operators described above:

Doc10.jpg

You can achieve similar without nesting, but take care of the order of your searches and operators:

Doc9.jpg

Some (or all?) of these results can of course be achieved using other search modes, I just wanted to focus on the compound search mode in this blog post. I hope all mysteries of the compound search have been revealed.

If you have any comments or questions, drop a comment below.

Have fun!


edits:
2016-02-02: Complement can be created easier, just using (* ^ *Sally*), added some more examples, reorganized some parts

Comments
swuehl
MVP
MVP

Max,

minus will work as NOT in a compound search?

Could you give an example (list bar search term using the example set from above)?

I would be very interested to see, haven't managed to do so.

Thanks,

Stefan

0 Likes
tresesco
MVP
MVP

Hi Stefan,

I have been able to do it like:  (Not like *String*) , i.e. - in combination with 'like'.

edit: removed quotes

PrashantSangle

Hi,

I have tested below cases in your example

1: if we just search with -h or -H It will exclude all the value which is started with h/H

exclude started with h.PNG

It is excluding "Harry" , "Harry & Sally" and "New Hampshire"

and Modify to above search with -Har. It is excluding only those value which is started with har

exclude started with har.PNG

It is excluding "Harry" , "Harry & Sally" and not "New Hampshire"

Also if we want to exclude multiple value then we can exclude it like

-string1 -string2

exclude multiple value.PNG

2nd way is already suggested by Tresesco

Regards

ecolomer
Master II
Master II

Very good job

Thank's for sharing

Saludos,

Enrique Colomer

0 Likes
swuehl
MVP
MVP

Max,

thank you for the examples.

Yes, it's possible to exclude values that show words that begin with the search term using '-'.

I think this is part of the normal search mode (since it seems you can't add wildcards) and mentioned also in the cheat sheet by Arturo.

It's of course a good idea to use this search mode if your search requirements fit (e.g. beginning of word known, no wildcards).

I tried to focus my document specifically on the compound search mode and I couldn't make the minus operator work as NOT in this specific search mode.

So, up to now, I don't think the minus character '-' has any special meaning in compound search mode.

Regards,

Stefan

0 Likes
Chanty4u
MVP
MVP

nice..

0 Likes
swuehl
MVP
MVP

tresesco,

you are killing me.  I think I need to rename my to document to 'Compound search - 90% demystified'.

You are right, 'not like' seems to be an operator in the compound search. 'not' alone is not working, 'like' alone seems to have no meaning, too (Interestingly, 'not' seems to be a keyword, though, since a field value with a single 'not' won't be found by (not), compared to e.g. (me) in above sample set).

So, taking 'not like' as an operator, (not like *Sally*) does return the complement of wildcard search *Sally*.

But I start fighting with this "operator" using (not like "Sally") or (not like Sally). Try yourself.

Seems like 'not like' needs wildcards to operate correctly. Strange...

Honestly, I think there is something weird going on. IMHO, it's more than strange when QV developers trying to create a compound search with very compact syntax, they suddenly come up with a 'not like' operator.

Need to play a little more.

Thanks for the interesting finding,

Stefan

PrashantSangle

Hi,

You can also try - with () and ^ which exclude multiple search term but with limited scope.

Regards

0 Likes
tresesco
MVP
MVP

Stefan,

I never intend to kill someone whom I admire.

After testing a bit more I can only agree with you and post some results as you explained.Search7.png

'Like' alone doesn't work with wildcard but does without it.

Search6.png

NOT seems to work only in combination with LIKE and wildcards. May be Henric hic would have some pattern to suggest.

Thanks.‌

jvitantonio
Luminary Alumni
Luminary Alumni

This is very useful! Thanks for sharing. There are always new things to learn.

Juan

0 Likes
Contributors
Version history
Last update:
‎2022-09-21 01:01 PM
Updated by: