wks.col.filter

Syntax

wks.col.filter

wks.col.filter$

Type

numeric


string

Access

Read/write

Description

Add or remove a filter.
0 = remove filter
1 = add filter
2 = custom filter (read only)

Note: Filter properties are set by using these filter related scripts, but the filter will not run automatically, and the method wks.runfilter() needs to be called to run or re-apply the filter.


Set or get filter query string. It must set the filter type to advance.

Examples

EX1

This example shows how to set up a worksheet filter. In this example we have a column of temperatures where we wish only to show rows where the temperature is greater than 75. The last line of script allows the user to manually modify and reapply filter.
newbook;
col(1) = data(1,31);
col(2)=uniform(31)*10+70;
wks.col2.filter = 1;
wks.col2.filterx$ = "temperature"; // variable name we will use
wks.col2.filter$ = "temperature > 75"; // our filter condition
wks.runfilter();
wks.col2.filter(); // open the associated filter dialog box to modify filter


EX2

This example shows how to set column as categorical. This script imports data, filters the data, sets a column of data as categorical then sorts the filtered categories in ascending order using wks.col.categorical.sort. Ordering becomes important when creating the stack plot. Sorting in ascending order then plotting the stack "top to bottom" preserves alphabetical ordering of categories, from top to bottom.
// import automobile.dat to a new book
fn$ = system.path.program$ + "Samples\Statistics\automobile.dat";
newbook;
impASC fn$;
// apply filter to column = Make to show only Buick Chrysler GMC Lincoln Saturn
wks.col2.filter=1;
wks.col2.filterx$ = make;
wks.col2.filter$ = "make="Buick" or make="Chrysler" or make="GMC" or make="Lincoln" or make="Saturn"";
wks.runfilter();
// set col(2) as categorical and sort in ascending order
wks.col2.categorical.type=2;
wks.col2.categorical.sort=1;
//refresh column filter
wks.runfilter();
// unstack worksheet to columns by make
wunstackcol -r 2 irng1:=[%H]automobile!C"Power" irng2:=[%H]automobile!B"Make" nonstack:=1 other:=[%H]automobile!A"Year" extract:=0;
// create stack plot of col(1) vs. col(2) to end, type=scatter
plotstack iy:=(1,2:end) plottype:=scatter order:=0 link:=1 xlink:=1;


EX3

This example shows how to remove column filter
wks.col2.filter = 0;
wks.runfilter(2); //force update even there is no filter

See also

wks.col.filterx, wks.col.filter(method), wks.col.categorical.type, wks.col.categorical.sort