Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
peter_turner
Partner - Specialist
Partner - Specialist

Apply a pre-made search string via action or macro

Hello Everyone,

I have a 'report.ini' file, with report names and filters to search my data by.
E.g
Orange Report =Fruit like 'Orange*'

I need to make a button (Action or Macro) that will apply the pre-made search string to my data, I've attached an example to show what I mean.

The idea being that I can make a large list of pre-made reports and search filters, and just add them to the report.ini file as needed.
This is similar to bookmarks, except my search string might not return any results.
If I tried to use a bookmark in this situation, it wouldn't store the raw search string I was using (as it wasn't able to make any selections).

I think i'll almost there, but not quite sure on the final stage.

Thanks,
Peter.

1 Solution

Accepted Solutions
biester
Specialist
Specialist

Hi Peter,

instead of "Filter" in SearchString try "=Filter". The thing is working here if I add the "=".

Rgds,
Joachim

View solution in original post

11 Replies
biester
Specialist
Specialist

Hi Peter,

instead of "Filter" in SearchString try "=Filter". The thing is working here if I add the "=".

Rgds,
Joachim

peter_turner
Partner - Specialist
Partner - Specialist
Author

Thanks again Joachim!
that was about the only thing i hadn't tried 🙂

johnw
Champion III
Champion III

I guess you have this working, but it seems like a pretty unusual approach to me. In my applications, I'd likely apply the filter at load time to build a new field, like "Fruit Category". So if(left(Fruit,6)='Orange','Orange',if(...)) as "Fruit Category". The user would then just select a Fruit Category of Orange rather than clicking on the Orange button. Or if you really want an Orange button, such as if you have a nice picture of an orange that they can click on, the action can be to select the Orange Fruit Category rather than all Orange Fruit. Just a thought.

mike_garcia
Luminary Alumni
Luminary Alumni

Hello,

Why is it that if you copy the exact same string generated by "=Filter" and place it on the Search String field, it does not work?

I've been trying to define a Search String to delect two values with that same expression but it does not seem to work out.

Any help, please?

Miguel García
Qlik Expert, Author and Trainer
johnw
Champion III
Champion III

The "=" syntax means you're specifying a QlikView expression that will be evaluated for each row of the list box, just like you'd made a chart with that as the dimension. Anything with a non-zero value will be selected. The "=" syntax is NOT a way of generating a normal search string.

Looking for two specific values using the "=" syntax could be done like this:

=match(MyField,'Value1','Value2')

mike_garcia
Luminary Alumni
Luminary Alumni

Thank you John! Your expression works in advanced search on a list box, but does not work with the 'Select in Field' Action. Any other workaround?

Thanks! Mike.

Miguel García
Qlik Expert, Author and Trainer
johnw
Champion III
Champion III

Our shop is still officially on 8.5. I have unofficially downloaded 9.0, but haven't played with the actions yet. It sounds like the actions simply don't support advanced searches. A potentially-painful workaround would be to code it as a macro, with all the headaches that can entail. I'm not thinking of anything else, but perhaps it's simple, and I just don't have enough 9.0 experience.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Mike,

The search string value can contain an expression. So to generate an expression as a search argument, you have to use this syntax.

='=expression'

Note that you have to generate the "=" as part of the expression result. So to use a match expression for the field named Key for values 'A', 'B' the search string box value would be:

='= match(Key, ' & chr(39) & 'A' & chr(39) & ',' & chr(39) & 'B' & chr(39) & ')'

It gets a bit ugly because of the need for quotes. There might be a simpler syntax, but you get the idea -- include a leading "=" in the expression result.

-Rob

mike_garcia
Luminary Alumni
Luminary Alumni

Great! It works!

Thank you very much Rob!

Miguel García
Qlik Expert, Author and Trainer