metrics {Array<Metric>}

The metrics property can be used to specify a list of dataset fields to apply an aggregation function on. Only use this property when creating aggregated queries.

The metric object contains the following properties:

  • name {string}: The name of the field to request
  • func {string}: The aggregation function to apply to the field. Valid values: avg, min, max, sum, distinct_count, last_value, calc, percentiles
  • args {Array}: Optional - Used only when the func property is percentiles. Valid values: 0, 25, 50, 75, 100
Note: When using the 'metric' property, omit the 'fields' property


const metrics = [
  { name: 'price', func: 'sum' },
  { name: 'city', func: 'distinct_count' },

Try this example on CodeSandbox

Updated Jan 10, 2019