We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.
All documentation
  • Introduction
  • Connecting to data source
  • Browser compatibility
  • Documentation for older versions
  • Aggregation functions

    In the pivot table, every cell displays an aggregated value of raw data records. An aggregation function determines how the data records are aggregated into the value.

    This guide describes which aggregation functions are available in Flexmonster and how to use them.

    Note If you are using the custom data source API, you can implement custom aggregations.

    Available aggregations

    The table below lists all aggregation functions supported by Flexmonster. To see which aggregations are available for each data source, refer to Flexmonster’s technical specifications.

    NameValueDescription
    Sum"sum"Calculates a sum of raw data records.
    Can be applied to fields of "number" and "time" types.
    Count"count"Counts a number of raw data records.
    Can be applied to fields of all types.
    Distinct Count"distinctcount"Counts a number of unique raw data records.
    Can be applied to fields of all types.
    Average"average"Calculates the average (arithmetic mean) of raw data records.
    Can be applied to fields of "number" and "time" types.
    Median"median"Calculates the median of raw data records.
    Can be applied to fields of "number" and "time" types.
    Product"product"Calculates the product of raw data records.
    Can be applied to fields of "number" and "time" types.
    Min"min"Calculates the smallest of raw data records.
    Can be applied to fields of "number", "date string", "datetime", and "time" types.
    Max"max"Calculates the largest of raw data records.
    Can be applied to fields of "number", "date string", "datetime", and "time" types.
    Population StDev"stdevp"Calculates population standard deviation for raw data records.
    The population standard deviation formula is the following:
    1. Calculate the average (arithmetic mean) of the data records.
    2. Subtract the average from each data record to get the deviations from the average.
    3. Square each deviation.
    4. Calculate the sum of the squared deviations.
    5. Divide the sum by n to get the population variance. n is the number of data records.
    6. Take the square root of the variance.
    Can be applied to fields of "number" and "time" types.
    Sample StDev"stdevs"Calculates sample standard deviation for raw data records.
    The sample standard deviation formula is the following:
    1. Calculate the average (arithmetic mean) of the data records.
    2. Subtract the average from each data record to get the deviations from the average.
    3. Square each deviation.
    4. Calculate the sum of the squared deviations.
    5. Divide the sum by n-1 to get the sample variance. n is the number of data records.
    6. Take the square root of the variance.
    Can be applied to fields of "number" and "time" types.
    % of Grand Total"percent"Calculates the percentage of a value compared to the grand total.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    % of Column"percentofcolumn"Calculates the percentage of a value compared to the column total.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    % of Row"percentofrow"Calculates the percentage of a value compared to the row total.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    % of Parent Column Total"percentofparentcolumntotal"Calculates the percentage of a value compared to the parent subtotal in columns.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    If there is one field in the columns, this aggregation works exactly like the "percentofrow".
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    % of Parent Row Total"percentofparentrowtotal"Calculates the percentage of a value compared to the parent subtotal in rows.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    If there is one field in the rows, this aggregation works exactly like the "percentofcolumn".
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    Index"index"Calculates the aggregated weighted average of a value. This shows the impact of each value within a dataset's context.
    The aggregated weighted average formula is the following: (value * grand total) / (row total * column total). The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    Difference of Column"differenceofcolumn"Calculates the difference between values in two adjacent cells of the same level. The calculation is done per column (from top to bottom). Note that the first row of each level will contain empty cells.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    Difference of Row"differenceofrow"Calculates the difference between values in two adjacent cells of the same level. The calculation is done per row (from left to right). Note that the first column of each level will contain empty cells.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    % Difference of Column"%differenceofcolumn"Calculates the percentage difference between values in two adjacent cells of the same level. The calculation is done per column (from top to bottom). Note that the first row of each level will contain empty cells.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    % Difference of Row"%differenceofrow"Calculates the percentage difference between values in two adjacent cells of the same level. The calculation is done per row (from left to right). Note that the first column of each level will contain empty cells.
    The values are calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the values are calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    Running totals of Columns"runningtotalsofcolumn"Calculates running totals (cumulative sum) of values in column cells of the same level. The calculation is done from top to bottom.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.
    Running totals of Rows"runningtotalsofrow"Calculates running totals (cumulative sum) of values in row cells of the same level. The calculation is done from left to right.
    The value is calculated based on the "sum" aggregation for fields of "number" and "time" types. For other field types, the value is calculated based on the "count" aggregation.
    Can be applied to fields of "string", "number", "month", "weekday", "date", and "time" types.

    Limit available aggregations

    You can also limit the list of available aggregation functions:

    Choosing an aggregation

    You can choose an aggregation in the following ways:

    • Choose via UI
    • Preset in the report
    • Apply using API calls

    Via UI

    To choose an aggregation function for a measure via UI, use the sigma icon in the Field List:

    Note You can control the visibility of the sigma icon using the showAggregations option.

    In the report

    To apply an aggregation to a measure in the slice, specify the name of an aggregation in the aggregation property:

    report: {
    dataSource: {
    filename: "https://cdn.flexmonster.com/data/data.csv"
    },
    slice: {
    measures: [
    {
    uniqueName: "Price",
    aggregation: "average"
    }
    ]
    }
    }

    Note If the aggregation is not specified, its default value is either "sum", "count", or "min", depending on the field's type.

    Using API calls

    To change an aggregation function applied to a measure, use the runQuery() method:

    const slice = pivot.getReport().slice;
    slice.measures[0].aggregation = "distinctcount";
    pivot.runQuery(slice);

    See also