aggregateFilters {Array<AggregateFilter>}
Aggregate filters can be used to filter an aggregate query’s result set to rows where the aggregate values meet the specified conditions.
Integer
, number
, and calculation
fields are the only types of Zoomdata fields that are valid when creating aggregate filters.
An aggregate filter object contains the following properties:
- metric {object}: A Zoomdata metric 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 aggregate filters of the following type:
Comparison & Equality Aggregate Filters
Comparison & Equality aggregate filters specify a condition on a metric with an operation and a single value. This type of aggregate filter uses the following operations:
- EQUALS: Keep the results where metric value
equals
the specified value - NOTEQUAL: Keep the results where metric value
does not equal
the specified value - LT: Keep the results where the metric value is
less than
the specified value - LE: Keep the results where the metric value is
less than or equal to
the specified value - GT: Keep the results where the metric value is
greater than
the specified value - GE: Keep the results where the metric value is
greater than or equal to
the specified value
Example:
const aggregateFilter = {
metric: {
field: { name: 'price' },
function: 'SUM',
type: 'FIELD',
},
operation: 'GE',
value: 100000,
};
Try this example on CodeSandbox
In/Not-In List Aggregate Filters
In/Not-In aggregate filters specify a condition on a metric with an operation and multiple values. This type of aggregate filter uses the following operations:
- IN: Keep the results where the metric value is
in
the specified list of values. - NOTIN: Keep the results where the metric value is
not in
the specified list of values.
Example:
const aggregateFilter = {
metric: {
field: { name: 'price' },
function: 'AVG',
type: 'FIELD',
},
operation: 'IN',
value: [1225, 1350, 1800],
};
Try this example on CodeSandbox
Between Aggregate Filters
Between aggregate filters specify a condition on a metric with the BETWEEN
operation and 2 values.
This type of aggregate filter keeps the results where the metric value is between
the 2 specified values.
Example:
const aggregateFilter = {
metric: {
formulaName: 'Sum of 15 pct price',
type: 'CALCULATION',
},
operation: 'BETWEEN',
value: [20000, 30000],
};
Try this example on CodeSandbox
Updated Jan 10, 2019