Step: Filter
Overview
The Filter step selects rows that meet a certain set of conditions.
Example starting data:
/*---------+--------*
| student | score |
+---------+--------+
| jane | 83 |
| neal | 35 |
| sam | 74 |
| pat | 62 |
*---------+--------*/Example output data:
Filter out rows with scores less than 70.
/*---------+--------*
| student | score |
+---------+--------+
| jane | 83 |
| sam | 74 |
*---------+--------*/Step structure:
Basic state

A filter step will be made up of one or more filter blocks with a completed condition.
When there are multiple filter blocks in a step, conditions in all blocks must be met for rows to be kept.
If you have a more complex filter statement that is dependent on multiple nested conditions you can select
+to expand the filter block.
Expanded state

When multiple conditions are needed in a block, you must specify how they relate to each other (
ANDvsOR).Any nested conditions are resolved before higher level conditions.
Field descriptions
Variables
The variable whose values will be evaluated.
Depending on the operator selected, it may contain multiple variables. Use wildcard characters, such as *, for bulk selection.
[Operator]
How the two sides of the condition will be evaluated.
Value(s) or Variable(s)
The variable or value which the previously chosen Variables will be evaluated against.
Depending on the operator selected, it may contain multiple variables, values, or a parameter. Use wildcard characters, such as *, for bulk selection.
Examples
Example 1: Basic filter
Lets say we only want to reduce our table to only contain information about results from the final test.
Starting data:
Input fields:

Variables: The variable
testis where thefinalvalue we want to evaluate on is located.[Operator]: We want fields that match exactly, so we choose
=.Values or variables: We want to only keep rows where
finalis present, so we put that here.
Output data:
Example 2: Multiple conditions
Let's say we don't just want values from the final but, only those from the final with a score above 60.
Starting data:
Input fields:

We input the data as in the above example, but since we now have two conditions, we have to decided how they relate to each other. In this case we want data that meets all the conditions so select
All conditions must be satisfied (AND).
Output data:
Example 3: Nested conditions
Let's say we want to keep all data from the final greater than 60, or any any scores above 85.
Starting data:
Input fields:

We want to keep all rows where scores are over 85, or where the test is
finaland the score is over 60. So we set up thefinaland over-60 conditions under anANDgroup, and nest that group under the top-levelORcondition, alongside the condition for scores over 85.When executed, the nested condition (test is
finaland score is over 60) is evaluated first, resolving to true or false. Then the higher-level condition, score over 85, OR (test isfinaland score over 60), is evaluated. Any rows that meet this higher-level condition are kept in the output. Any that don't are discarded.
Output data:
Example 4: Comparing variables and value lists
Let's say we only want to keep rows where scores are greater than the average score and for selected students. Right now our selected students are Jane and Pat but we know that might change in the future.
Starting data:
Input fields:

First, create a value list called
selected_studentswith the valuesjaneandpat. Then select it as the comparison forstudent.With multiple inputs on either side of a condition, the condition is evaluated as an OR. So this condition evaluates to true if the value in
studentequals any value on the list (janeorpat).The same result could be achieved by entering
janeandpatdirectly into the right side of this condition, but using a list makes it easy to change the selected students centrally later, updating every place the list is used.
For the second condition, compare two values from the same row against each other.
When executed, this condition checks whether the value in
scoreis greater than the value inscore_averagefor each row. If so, the condition is met.
Output data:
Reference: Comparison statements
A comparison always evaluates to either TRUE or FALSE.
Comparisons are made up of one or more comparison rows. A comparison row always evaluates to TRUE or FALSE. Multiple rows can be nested with a logical AND/OR.
A comparison row is made up of three components:
1. Left expression
The left expression can contain variable parameters from the source table, joined tables, and any newly created variables. All referenced new variables must be "upstream" from the current comparison, with the exception of joins. Joins may reference new variables that are constructed by any variables upstream of that join.
Depending on the operator selected, the left expression may contain multiple variables. In this case, each left expression will be evaluated against the right expressions, and logically joined via an OR. If you want to take the logical AND of multiple variables, create a separate comparison row for each variable.
Multiple left hand values are only supported for = and like operators.
2. Operator
Redivis supports the following operators:
=, !=
Checks if any the values in the left expression are equal or not equal to any values in the right expression. NULLs are treated as equivalent (NULL == NULL -> TRUE and NULL != NULL -> FALSE)
>, >=, <, <=,
Checks if the value in the left expression is less than, greater than, etc. the right expression. String comparisons are lexicographically ordered, other data types are based on the numeric / temporal order of that value. Comparisons between NULL values will always be false.
like / ! like
Checks if the strings in the left hand expression matche the specified patterns in the right hand expression. The pattern may contain the following characters:
A percent sign
%matches any number of charactersAn underscore
_matches a single characterYou can escape
\,_, or%using a single backslash. For example,\%.
Right expression
The right expression can contain any variables allowed in the left expression, as well as literal values and lists. The comparison row will evaluate to TRUE when the left hand expression matches any of the right hand expressions, except for the != and !like operators, where the comparison will evaluate to true if all values are not equal to or not like the left expression.
To match against a null datum (empty cell), you must specify the special literal value NULL here.
Last updated
Was this helpful?

