Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
];
[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,'?') ]
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*)
[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:
You can achieve similar without nesting, but take care of the order of your searches and operators:
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
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
Hi Stefan,
I have been able to do it like: (Not like *String*) , i.e. - in combination with 'like'.
edit: removed quotes
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
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
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
2nd way is already suggested by Tresesco
Regards
Very good job
Thank's for sharing
Saludos,
Enrique Colomer
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
nice..
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
Hi,
You can also try - with () and ^ which exclude multiple search term but with limited scope.
Regards
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.
'Like' alone doesn't work with wildcard but does without it.
NOT seems to work only in combination with LIKE and wildcards. May be Henric hic would have some pattern to suggest.
Thanks.
This is very useful! Thanks for sharing. There are always new things to learn.
Juan