groups {Array<Group>}

The groups property can be used to specify a list of dataset fields to use for grouping the result set. Using this property in a query configuration creates an aggregated query.

A group object contains the following properties:

  • name {string}: Name of the field in the data source
  • type {string}: Optional - Valid only when using a TIME field for the name property. This should be set to to TIME
  • func {string}: Optional - Valid only when using a TIME field for the name property. Valid values: MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
  • includeBlanks {boolean}: Optional - Valid only when using a TIME field for the name property. By default, time groups do not show missing values in a time range. Set to true to include NULLs.
  • form {string}: Optional - Valid only with fusion sources. Specifies the name of the form
  • limit {number}: Max number of values in this group
  • sort {object}: Sort definition. Used in conjunction with the limit
Note: When using the 'group' property, omit the 'fields' property

The sort object contains the following properties:

  • name {string}: The name of the field to use for sorting
  • metricFunc {string}: Optional - If name is a numeric fields, specify aggregation function to use for the sorting operation. Valid values: avg, min, max, sum, distinct_count, last_value, calc
  • dir {string}: The direction of the sorting operation. Valid values: asc, desc

Example:

const groups = [
  {
    name: 'payment_type',
    limit: 5,
    sort: { name: 'price', metricFunc: 'sum', dir: 'desc' },
  },
  {
    name: 'country',
    limit: 3,
    sort: { name: 'country', dir: 'asc' },
  },
];

Try this example on CodeSandbox

Updated Jan 10, 2019