Search Results for

    Show / Hide Table of Contents

    Aggregate functions

    Aggregate functions are used in data cells to aggregate cell values and to calculate totals. An aggregate function call looks like this:

    [Function(Expression)]
    

    Square brackets are used to specify expressions in cell text. You can use multiple aggregate functions in one cell along with regular text.

    Expression is usually a data source field. An example of using an aggregate function:

    [Sum([MatrixDemo.Revenue])]
    

    Below is a list of aggregate functions:

    Function Description
    Sum Returns the sum of values.
    Min Returns the minimum value.
    Max Returns the maximum value.
    Avg Returns the average value.
    Count Returns the number of values.
    CountDistinct Returns the number of different (unique) values.
    StDev Returns the standard deviation of a sample.
    StDevP Returns the standard deviation of a population.
    Var Returns the variance for a sample.
    VarP Returns the variance for a population.
    First Returns the first value.
    Last Returns the last value.
    ValuesList Returns a list of all values found in a cell. This aggregate is used to work together with the "Diagram" and "Sparkline" objects.
    _name Custom aggregate function defined in the report code.

    A custom function has a name that begins with an underscore. Its code should be placed in the body of the main report class, ReportScript. The function is defined as follows:

    object _FuncName(List<dynamic> l)
    

    Example of a custom function _Sum:

    public class ReportScript
    {
        public object _Sum(List<dynamic> l)
        {
            dynamic value = 0;
            foreach (dynamic v in l)
                value += v;
            return value;
        }
    }
    
    Back to top © 1998-2025 Copyright Fast Reports Inc.