What is a Filter?
A filter can limit dimension values and summary values. In DiveTab, filters can either be applied to the build, cplan, or divetab file through Workbench.
When a filter is applied to a build file, the build result includes the filter. When a filter is applied to a cPlan, every instance where the cPlan is implemented uses that filter. When a filter is applied to a data page or element, the filter is used in only those instances.
Here is a
filter used in a Build file.
Every time the specified cBase is used, the filters apply.
Here is a
filter used in a cPlan file.
Every time this cplan is used, this filter applies. Only data for Resp SalesPerson dimension value Tony is presented.
Here is a
filter applied to the cPlan of a report-page block.
Notice how the filters are applied within the report-page block. This means that only that particular report page is affected. Only values greater than 100 for 9 Liter Cases are shown for Resp Salesperson value Tony.
NOTE: When the line of code for the expression is too long, the normally single backtick, `, can be replaced with three backticks, ```, in order to divide the code between several lines.
The different types of filters can be sorted into two categories:
- Filters applied to dimension values (including dates, such as year and period of time)
- Filters applied to summary values
NOTE: Make sure that the dimension value is exactly as it appears in the cPlan or the cBase; values are case-sensitive—if they do not match what is in the script, they do not display.
IMPORTANT: Dimension value filters are contained within the cplan block.
= Filter
This filter only includes the dimension value you specify. It means "equals."
!= Filter
This filter includes every dimension value except for the value you specify. It means “does not equal.”
or Filter
This filter includes all the data from the two or more dimension values you specify. It means “or,” so it looks for the named values and filters out all other values. Each value must include a specified dimension. This can be the same dimension, or different dimensions.
is_in Filter
This filter is similar to the “or” filter, except that a dimension is defined once and then the values are listed. All values mentioned must be in the dimension specified. This allows you to list the dimension once, and then list multiple values in that dimension. Values not specified for that dimension are not included.
and Filter
This filter looks for data that apply to all the dimensional values listed. It means “and”, so the data must be specific to all value filters. This filter requires the use of two different dimensions; if you were to use the same dimension, you would get an empty set. Data cannot have multiple values under one dimension.
The and Filter can also be expressed in two separate lines.
The and filter can also be used in conjunction with other types of filters.
Date Value Filters
Date value filters are used to filter data by periods of time. Though the filters are similar to those for summary values, date value filters are written differently in the code and are displayed as dimensions.
Since the dimension values for Posting Period are written as Year-Month, you can also filter more exactly by including the month. For example, October of 2016 would look like 2016-10. It is important that the dimension values match the format used in the cPlan, or the filter does not work properly.
Summary value filters use numerical data, so it is possible to use more mathematical filters in the process. Since these values are integers, they do not need quotation marks in the code.
NOTE: You can filter on a calc, such as Cases MTD Y-1, without displaying it as a column.
Summary value filters are contained in the page type block.
= Filter
This filter looks for summary values that equal a specified value. This filter is exact; if there are no values that equal the filtered value, there is no matching data and therefore no results.
> Filter
This filter includes any data that is greater than the specified number. It means "greater than," so all numbers greater than the filtered summary value are included; all numbers less than or equal to the filtered value are excluded.
< Filter
This filter includes any data that is less than the specified number. It means "less than," so all numbers less than the filtered summary value are included; all numbers greater than or equal to the filtered value are excluded.
notnull Filter
This filter excludes data values that are blank. For example, if there is no SCC Code for County Cayuga, all information related to that county, including the Cost and Cases, is excluded from the page. This filter is used primarily by summaries, but dimensions that are used as text columns can also use this filter.
report-page {
cplan "/cplans/basic_101.cplan" {
filter `notnull(value("SCC Code"))`
}
title "NotNull Summary Filter"
dimension "County"
text column = "Cost" {
value-format "$#,###.00"
}
text column = "Cases"
text column = "SCC Code"
}
IMPORTANT: Zero (0) does not count as a null value.