Column filters

Column filters is a mechanism that allows to limit displayed data by only including the rows that meet criteria that you specify and hides rows that you do not want displayed. Criteria can be related to values in one or more columns, hence the column filter term. After you filter data, you can browse the resulting rows like before. Adding, editing or removing filters does not affect the actual data, it only limits amount of data displayed.

Table of Contents

Creating basic column filters

Basic filter can be created "by example" using context menu or using the Column Filters Editor window for given tabular view.

Figure 1. Column filter consisted of two rules created for the Peaks table of a Byomap document

This filter contains two rules:

"Show rows having Apex Time values larger than 42.80 and having Normed area % values smaller than 8.0 %.

Rules of basic filters are always combined using the conjunction (AND). For given row all the rules must be evaluated successfully or else the row will be filtered out. To overcome this limitation so OR, negation and more complex logical rules can be supported, filters can be defined using scripting. See the Script column filters section for more information.

Supported basic filter operators

=, ≠, <, ≤, >, ≥ operators

These operators require one argument of type that matches column type. Text matching is case-sensitive. For floating point numbers comparisons are limited to number of significant digits currently specified for given column.

These are well-known math operators, as follows:

Operator Description
= Equal to the compared value
Not equal to the compared value
< Less than the compared value
Less or equal than the compared value
> Greater than the compared value
Greater or equal than the compared value

"Is empty", "Is not empty" operators

These operators require no argument and can be used with any type.

Operator Description
Is empty Accepts values that are empty (they are empty strings or the value is missing)
Is not empty Accepts values that are not empty (they are not empty strings or the value is of other type exists)

"Starts with", "Does not start with", "Ends with", "Does not end with", "Contains", "Does not contain" operators

These operators require one argument of text type. Before matching, values are first converted to text if the type is not text. Text matching is case-insensitive.

Operator Description
Starts with Accepts values having textual representation starting with given text
Does not start with Accepts values having textual representation not starting with given text
Ends with Accepts values having textual representation ending with given text
Does not end with Accepts values having textual representation not ending with given text
Contains Accepts values having textual representation containing given text
Does not contain Accepts values having textual representation not containing given text

"Like", "Not like" operators

These operators require one textual argument that is a wildcard pattern. Text matching is case-insensitive.

Operator Description
Like Accepts values having textual representation matching specified wildcard pattern
Not like Accepts values having textual representation not matching specified wildcard pattern

Format of the pattern is similar to command shells such as GNU bash or cmd.exe. Following rules apply:

The backslash character \ escapes special characters ?, *, [ and ] and \ itself. For example \? adds the ? character to the pattern.

"Matches", "Does not match" operators

These operators require one textual argument that is a regular expression pattern. Regular expressions are more complex but also more powerful than the wildcard patterns of the Like operator. Text matching is case-insensitive.

Format of the regular expression pattern is based on so called Perl-compatible regular expressions (pcre). Detailed information can be found in the Perl's regular expression documentation and the Perl's regular expression tutorial. Following are most frequently used rules:

Script column filters

Script column filters is an extension of the basic filters. Instead of creating rules using the graphical interface, user programs the filters using the JavaScript language, programming language known from the Web. Basic knowledge of the language is useful but ability of writing mathematical expressions is often sufficient to build relatively advanced script filters.

Following is a script code that is equivalent of the two rules from the Creating basic column filters section.

return Column.value("Apex Time") > 42.80 && Column.value("Normed area %") < 8.0

&& means AND, Column.value provides value for a column (column is pointed by name). Type of both columns is numerical so their values are compared to numeric constants using comparison operators < and >.

Requirements for the script column filters

Script column filter is a program in JavaScript language. All parts of the script have to construct a valid program, both in terms of JavaScript syntax and used functions and constants. One or more syntax or name errors results in an invalid script which does not work as a column filter. The script can also use JavaScript-compatible comments.

Example: This script gives a name error because abc is undeclared identifier:

return abc

Example: This script gives a syntax error because return keyword is misused:

if return

Example: This script gives a runtime error assuming that the "Foobar" column is not present:

return Column.value("Foobar") > 0

Script column filter is a program that returns boolean value. The program returns a boolean value by returning a true or false constant or more complex expression that evaluates to a boolean constant. This means that only expressions that are evaluated to a true or false value are valid expressions. Empty expression is invalid. Returning is performed using the standard JavaScript return keyword. If this keyword is missing, entire script column filter is invalid.

Example: valid script:

return false;

Example: invalid, missing return keyword:

true

Meaning of invalid column filter script programs. Applying invalid script program to a table of data results with filtering-out entire data. Invalid programs are thus equivalents of a program that always returns false value. In addition, applications can show approximate location of error within text of the invalid script and reason of error.

Blocks of commands. The requirement of returning a boolean value does not mean that scripts have to only contain a single boolean expression. Column filter script can be based on any valid JavaScript program, that is, block of commands, assuming that correct return command is present on the end.

Example script consisted of a block of commands:

var width = 150;
var height = 20;
var area = 15  *20;
return Column.value("Area") > area; // assuming the "Area" column exists, it's a valid program

Debugging functions for script column filters

Column filters presets

Creating column filters and adjusting their parameters can be time-consuming. To preserve the work applications offer presets for the column filters defined by the user.

Single preset stores one or more column filters of any kind. There are two locations where presets can be stored:

Presets that are saved in the current document have names (descriptions) that can be any non-empty text. Presets that are exported to files have names that are just filenames. Extension for a preset file is cft.

To access functions of Presets click the bottom-left Presets button in the Column Filters Editor window. Supported commands are: