Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Filter a List box based on specific name

Hi,

I am trying to filter a list box that has names is it. I want only the names I tell it to show in the list box and all the other names to disappear. Is there an expression I could write where I can put in the names I want the list box to show.

Thanks

Alam

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

you can create a flag in Script for the names you want to show in your listbox:

Load

Fields,

Name,

if(match(Name, 'X', 'Y', 'Z'), 1) as nameFlag

From XY;

in your listbox  choose <expression> and enter if(match(nameFlag,1), Name)

Best regards

Stefan

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Hi,

you can create a flag in Script for the names you want to show in your listbox:

Load

Fields,

Name,

if(match(Name, 'X', 'Y', 'Z'), 1) as nameFlag

From XY;

in your listbox  choose <expression> and enter if(match(nameFlag,1), Name)

Best regards

Stefan

Not applicable
Author

Stefan,

Is the 'Fields' after load mean the field names in my table?

and From XY, what does xy stand for the table name or a path to my qvd?

Anonymous
Not applicable
Author

Hi,

sorry. First load statement is the table where your Name field is contained. 'Fields' was meant to be all fields in that table and From your source. So simply add this script  line when you load the table where Name field is contained

if(match(Name, 'X', 'Y', 'Z'), 1) as nameFlag

hope this helps

-Stefan

Not applicable
Author

Oh I see, got it,

So I did this and this is what I get.


field,

field,

ASSIGNED, <--Field that im trying to filter.

If(match(ASSIGNED, 'Smith, Joe', 'Doe, Jane'), 1) as nameFlag,

field,

field,

..

..

List box is created with ASSIGNED, and expression I added is if(match(nameFlag,1), ASSIGNED)

I get "Bad field name(s); nameFlag ASSIGNED as error on the edit window, and the nameFlag is underlined in red.

Anonymous
Not applicable
Author

Are you likely to use this set of names for additional analysis in the future or for other charts?

If so, It is probably worth the time it would take you to create an additional table in your load script:

ReportNames:

Load * INLINE [

     PersonID, ReportName

     1234, Alam

     5678, Steve

];

This is just an example, you'd want some field you could link to the table that contains the name data you're looking for. Only include the names you want listed. You could also populate this table with a Load Resident statement and filter to get only the records you want.

Then just create a listbox with ReportName.

Once this is done, you can use ReportName elsewhere in your application as well and stay away from costly expression constructs involving IF statements and calculated dimensions, etc.

Anonymous
Not applicable
Author

Hi,

when you create the listbox do not choose ASSIGNED in the drop down list, choose <Expression>  and type if(match(nameFlag,1), ASSIGNED) in the dialogue.

The error however suggests that you field isn't spelled like ASSIGNED, did you reload after adding the line If(match(ASSIGNED, 'Smith, Joe', 'Doe, Jane'), 1) as nameFlag, ?

Best regards

Stefan