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

use a macro to select a single and multiple vaues from a listbox.

I want to write a macro which can select a single value from a listbox and then selects mutiple values from the same listbox.

So if I had a list box that displays A, B, C, D, E, F the fist macro could select (highlight in green) item B. The next macro needs to select more than one item so a valid result would be items A, C & D selected. (All 3 highlighted in green)
It doesn't really matter how you accomplish this. You could use two buttons. One with script to make a single selection and the second to make multiple selections.
Thanks & Regards,
Swati
7 Replies
Anonymous
Not applicable
Author

Hi Swati,

You can use the "Toggle Select" action. Here's the description from the F1-help:

Toggle Select

Toggles between the current selection and the specified Field and Search String. In the Search String you can specify a search mask, e.g. (A|B) will select both A and B.



Not applicable
Author

Hi Johannes,

I tried this but it didn't work. Request you to elaborate on it a bit more.

I have a listbox with some values, and I have a button. On click of this button, I want to select single and mutiple values in the listbox.

What should I mention in the field in case of multiple selections?

Regards,

Swati

Anonymous
Not applicable
Author

Hey Swati,

I'm not quite sure what you mean by selecting single and multiple values. Either you select one, single, or many, multiple.

In the "Field" section you type the name of the field in which you want to make the selections, for example "Year". And then in the Search string box you can type the values that you want to select, for example "(2006|2008|2009)". That should do it.

Not applicable
Author

Please refer to the attached Macro.qvw file. I have a listbox named Scorecard_Data and I have a button named Multiple Selections.

On click of this button, I want multiple values from the listbox to be selected, say, for example, Scope, Category,Comment.

Please show the same in the attcahed qvw file, and send it back to me again.

Thanks & Regards,

Swati

Anonymous
Not applicable
Author

Hi Swati,

First off.. you can't set the listbox to "Always one selected value" and then select more than one value. But here you go, check the attached file.

Not applicable
Author

Hi Johannes,

Thanks for your reply. Its working perfectly fine.

But I didn't get one thing. In the Field, you have mentioned $Field, what does that signify?

I mean had there been mutiple list boxes, and I had to select values from one of those listboxes, how would have we been able to identify that particular listbox? Please explain.

Thanks & Regards,

Swati



Anonymous
Not applicable
Author

Heya Swati,

If you look at the properties for the listbox, there's a little box that says Field and contains the name of the field that you show in the listbox. That's the field that you want to make the selection in.

$Field is a system field in the QlikView document containing the names of all available fields in the document (which is why it's preceded by a dollar-sign)