Skip to main content
Mail a PDF copy of this page to:
(Your email address will not be added to a mailing list)
Show menu Show menu


A filter is a logical expression which evaluates to 1 (= TRUE) or 0 (=FALSE). For every case in the spreadsheet, this expression is evaluated and if the result is TRUE, the case is included in the analysis or graph but if the result is not TRUE, then the case is excluded from the statistical analysis or graph.

1. Simple filter

A basic filter exists of a variable, a comparison operator and a constant value. The comparison operators are:

<Less than
>Greater than
<=Less than or equal to
>=Greater than or equal to

For example, if you have the following data in the spreadsheet:

Data sheet

then the expression AGE>40 can be used as a filter:

Filter example

When the cursor (the focus) is on a Filter selector, then you can press function key F8 to call the Filter formula editor for an easy to use formula editor.

When MedCalc calculates the summary statistics for the variable WEIGHT, it will evaluate the expression AGE>40 for every case. MedCalc will only include the cases for which the expression evaluates to the logical value TRUE.

Other examples of filters:

TREATMENT="A" : Treatment must be equal to "A" - notice the use of quotation marks for a text constant in formula.

AGE<=60 : Age must be less than or equal to 60

ROW<21 : Only the first 20 cases in the spreadsheet will be selected (see ROW)

VARY<>"" : Only process cases where the variable VARY is not empty (can contain text or numbers)

ISNUMBER(VARY) : Only process cases where the variable VARY is a number

2. Combined filter

Different filters can be combined into one single filter using the logical functions AND, OR and NOT, e.g.

AND(AGE>40,AGE<60) : only cases with age more than 40 and less than 60 will be selected.

AND(AGE>40,TREATMENT="A") : only cases with age more than 40 and treatment "A".

OR(AGE>40,TREATMENT="A") : cases with age more than 40 or treatment "A" will be selected.

AND(AGE>40,OR(TREATMENT="A",TREATMENT="B")) : cases with age more than 40 and treatments "A" or "B" will be selected.

When you have used a filter, you should check the resulting sample size and verify that the cases you intended to be selected have indeed been selected, and that you did not make a logical error in composing the filter formula.

In the examples above, a comma is used to separate arguments in the AND and OR functions. In most European countries, the comma is used as decimal symbol, and a semicolon is used to separate arguments, e.g., AND(AGE>40;AGE<60).

The list separator is an option in the Windows control panel and MedCalc uses this setting by default. This behavior is the same as in for example Excel.

You can however change the list separator symbol used by MedCalc in the Options panel (Regional settings tab).

See also