Reducer is just a simple function which takes an array of real numbers and returns a representative number by reducing the array. A reducer can only be applied on a measure. When groupBy is applied on a DataModel, it performs aggregation on all measures with a reducer function. Reducer function for a measure can be set from schema or it can be overridden when groupBy is called.

DataModel provides reducers which can be used out of the box

Reducer Name Description
sum returns the sum of all the number
avg returns the avg of all the number
min returns the minimum of all the number
max returns the maximum of all the number
first returns the first number in an array
last returns the last number in an array
count returns number of elements in the array
variance returns the variance of the numbers from the mean
std returns the standard deviation of the numbers
// An function to calculate mean squared value of an array.
function (arr) {
     const squaredVal = => item * item);
     let sum = 0;
     for (let i = 0, l = squaredVal.length; i < l; i++) {
         sum += squaredVal[i];

     return sum;



Array of Number

array of numbers which needs to be reduced to a single number.


Number: single representative number