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

How do I use a trigger to search for some values and exclude others?

Example - say I have a field which has the following values;

sunshine

sunbeam

sunny

sunscreen

nightime

daytime

I'd like to allow a user to enter a search term via an input box e.g. sun* and have another input box where they can specifically exclude a value e.g. suns* so the resulting selected list would be sunbeam, sunny.

I'm using triggers to do it but it's not working for some reason. It worked ok until I tried to add the NOT code.

Any ideas?

Thanks

1 Solution

Accepted Solutions
Gysbert_Wassenaar

See attached example.

Edit: there are two triggers, one for each variable. When the value of one of the variables changes the trigger for that variable fires and executes a Select in Field action. You can see the parameters for the action by opening the document properties window, go to the Triggers tab, select a variable and click on the Edit Action(s)... button below the OnInput label. The search string definition is an expression that creates list of values (just like in the text box) in the correct search string format.


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
luciancotea
Specialist
Specialist

Let's say you have two variables in your inputbox: vInclude and vExclude. Then you can use this macro (or it's equivalent in trigger commands):

SUB FilterColumn

   ActiveDocument.Fields("urlPhoto").Select  getVariable("vInclude")

   ActiveDocument.Fields("urlPhoto").ToggleSelect getVariable("vExclude")

END SUB

FUNCTION getVariable(varName)

set v = ActiveDocument.Variables(varName)

getVariable = v.GetContent.String

END FUNCTION

Gysbert_Wassenaar

See attached example.

Edit: there are two triggers, one for each variable. When the value of one of the variables changes the trigger for that variable fires and executes a Select in Field action. You can see the parameters for the action by opening the document properties window, go to the Triggers tab, select a variable and click on the Edit Action(s)... button below the OnInput label. The search string definition is an expression that creates list of values (just like in the text box) in the correct search string format.


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you Gysbert that works a treat! As I'm fairly new to Qlikview, are you able to explain in some words what the trigger is doing?

Not applicable
Author

Hi,

I've added another input field so that a user can choose whether to select ANY or ALL search terms and have modified the triggers but it doesn't seem to be working as I'd like it to. It only seems to work if the user presses enter after the third input box but I'd like to allow them just to change the first input box and the correct selection be made. I've attached my example document. If you add the text ,*day* to the first input box it seems to work the first time but after that it doesn't work correctly if only that input box is changed (I hope this is making sense!).

Do you have any ideas what I'm doing wrong?

Many thanks for any assistance as I've been staring at this for some hours now!!

Elaine