filters {Array<Filter>}
Filters can be used to filter out rows before aggregations occur or to exclude rows from unaggregated result sets. All of the Zoomdata field types are valid when creating a filter.
An aggregate filter object contains the following properties:
- path {object}: A field Zoomdata field object
- operation {string}: A Zoomdata filter operation
- value {number | string | Array<string | number>}: Value(s) to use in the filter
With these three properties, you can filters of the following type:
- Comparison & Equality Filters
- In/Not-In List Filters
- Between Filters
- Case-insensitive Text Filters
- Text Search Filters
- Boolean Filters
Comparison & Equality Filters
Comparison & Equality filters specify a condition on a field with an operation and a single value. This type of filter uses the following operations:
- EQUALS: Keep the rows where metric value
equals
the specified value - NOTEQUAL: Keep the rows where metric value
does not equal
the specified value - LT: Keep the rows where the metric value is
less than
the specified value - LE: Keep the rows where the metric value is
less than or equal to
the specified value - GT: Keep the rows where the metric value is
greater than
the specified value - GE: Keep the rows where the metric value is
greater than or equal to
the specified value
Example:
const filter = {
path: { name: 'payment_type' },
operation: 'EQUALS',
value: 'Visa',
};
Try this example on CodeSandbox
In/Not-In List Filters
In/Not-In filters specify a condition on a field with an operation and multiple values. This type of filter uses the following operations:
- IN: Keep the rows where the metric value is
in
the specified list of values. - NOTIN: Keep the rows where the metric value is
not in
the specified list of values.
Example:
const filter = {
path: { name: 'payment_type' },
operation: 'NOTIN',
value: ['Diners', 'Amex'],
};
Try this example on CodeSandbox
Between Filters
Between filters specify a condition on a field with the BETWEEN
operation and 2 values.
This type of filter keeps the rows where the field value is between
the 2 specified values.
Example:
const filter = {
path: { name: 'transaction_date' },
operation: 'BETWEEN',
value: ['2009-01-10 00:00:00.000', '2009-01-15 23:59:59.999'],
};
Try this example on CodeSandbox
Case-insensitive Text Filters
Case-insensitive text filters specify a condition on a field with the EQUALSI
operation and a single text value.
This type of filter keeps the rows where the field value is a string equal
to the specified value while disregarding case sensitivity
.
Example:
const filter = {
path: { name: 'country' },
operation: 'EQUALSI',
value: 'united states',
};
Try this example on CodeSandbox
Text Search Filters
Text search filters specify a condition across all fields of type TEXT
in a source with the TEXT_SEARCH
operation and a single text value.
This type of filter is only valid in data sources powered by a Lucene
based search engine, like Solr or Elastic Search.
The filter keeps the rows where any of the TEXT
fields match the specified value.
Example:
const filter = {
operation: 'TEXT_SEARCH',
value: 'bed bugs',
};
Try this example on CodeSandbox
Boolean Filters
Boolean filters specify an AND
or OR
condition across a list of supplied filters.
This type of filters keeps the rows that intersect
from the result of each filter when using the AND
operation, and keeps the union
of the rows from the result of each filter when using the OR
operation.
Example:
const filter = {
operation: 'OR',
value: [
{
path: { name: 'country' },
operation: 'EQUALSI',
value: 'united states',
},
{
path: { name: 'city' },
operation: 'IN',
value: ['London'],
},
],
};
Try this example on CodeSandbox
Updated Jan 10, 2019