Date Posted:
Product: TIBCO Spotfire®
Product: TIBCO Spotfire®
Problem:
How to Create a Property Control Filter with Partial String Matching
Solution:
By default, the search in List Box and Text filters matches on the string from the beginning of each word only (searching for "an" will match "anvil" but not "banana"). It is possible to create a partial word match which will match your search string anywhere in the values by using using property controls and calculated columns. Assume a data table containing the countries of the world like:
# Country Population 1 Afghanistan 34169169 2 Albania 2911428 3 Algeria 41063753 ...Follow these steps:
- Go to 'Insert' > 'Text Area' to create a new Text Area
- Right click on the next Text Area, and select 'Edit Text Area'
- Go to 'Insert Property Control' > 'Input Field' to create a text 'Input Field' property control. Click 'New' to create a new property called 'searchString' of data type 'String' for the property control.
- Go to 'Insert' > 'Calculated Column' to create a calculated column called 'Filtered Country' with expression:
- If("${searchString}" != "" and [Country]~="${searchString}",[Country])
- In the Text Area, go to 'Insert Property Control' and create a 'List Box' or 'List Box (Multi select)' property control with:
- Click 'New' to create a new property called 'selectedCountries' of data type 'String' for the property control (if a multi-select list box is used, this will result in a 'String List' data type)
- Set property values in column: Unique values in column
- Column: Filtered Country
You can now search for "am" and it will match "American Samoa", "Bahamas", "Cambodia", etc. ("am" anywhere in the Country string) instead of just "American Samoa" and "United States of America" ("am" in the beginning of a word).
Option 1:
If you want all values to be displayed when no search filter is entered, remove this from the expression:
- "${searchString}" != "" and
- If([Country]~="${searchString}",[Country])
If you want to search for your string only in the beginning of the column values (i.e to only find values that start with the search string), add a "^" in the expression resulting in:
- If("${searchString}" != "" and [Country]~="^${searchString}",[Country])
Comments
0 comments
Article is closed for comments.