Reports for WinForms | ComponentOne
Working with C1Report / Grouping and Sorting Data / Adding Subtotals and Other Aggregates
In This Topic
    Adding Subtotals and Other Aggregates
    In This Topic

    C1Report supports aggregate expressions in all its calculated fields. The aggregate expressions include all the usual Sum, Avg, Min, Max, Count, Range, StDev, and so on.

    All aggregate functions take an expression as an argument and evaluate it within a scope that is determined by their position in the report. For example, aggregates in group headers or footers have the scope of the group. Aggregates in the report header or footer have the scope of the entire report.

    For example, the following aggregate expression would return the sum of all values in the Sales field for the scope of the aggregate (group or report): Sum(Sales)

    The following aggregate expression would return the total amount of sales taxes paid for all values in the report (assuming an 8.5% sales tax):Sum(Sales * 0.085)

    You can reduce the scope of any aggregate using a second argument called domain. The domain argument is an expression that determines whether each value in the current scope should be included in the aggregate calculation.

    For example, the following aggregate expression would return the sum of all values in the Sales field for products in category 1: Sum(Sales, Category = 1)

    The following aggregate expression would return the number of sales over $10,000: Count(*, Sales > 10000)

    Note: For the complete report, see report "13: Subtotals and other Aggregates" in the CommonTasks.xml report definition file, which is available in the ComponentOne Samples folder.