Skip to main content
In addition to specifying desired column names, providers accept aggregate functions as column parameters. These are called and referred to as aggregate columns. Aggregate columns are extremely useful when the results need to be transformed in a structured way. Aggregate columns can also nest other aggregate functions.

Aggregate functions

Data transformations can be as simple as returning a running count of a column, or as complex as including nested groups; with the use of multiple GroupBy functions. The default output of every archive provider are rows that include the specified detail columns.

Default row output

Detail Row => | Column1 | Column2 | Column3 | Column4 However, hidden as an option is the GrandTotal row. GrandTotal is a reserved placeholder for returning aggregate results, such as a total count or total sum. When specified in a provider’s GetRows method, i.e. provider.GetRows("GrandTotal=True"), the grand total row is output as the very last row. This is useful to display the results of one or more aggregate columns.

Default row output with GrandTotal

Detail Row1 => | Column1 | Column2 | Column3 | Column4
Detail Row2 => | Column1 | Column2 | Column3 | Column4
GrandTotal Row => | Function1 | Function2

Aggregate function modifiers

Function modifiers are used to set the behavior or output of an aggregate function. An aggregate function can include one or more modifiers, and the format is as follows: FunctionName(columnName)[:Modifer[,Modifier]...] HideDetail is commonly used when calculation results should only appear in the Header, Footer, and GrandTotal rows. Given the example Count(SaleId):HideDetail, the HideDetail modifier instructs the provider to not include this desired column in the row.ColumnData collection. It only makes sense to output headers or footers row when results are grouped. Therefore, the Header, Footer, and Integer modifiers are only used together with GroupBy. The Integer modifier is literally a number that specifies the nest level of a group. The first GroupBy function has a default level value of 1 and is not required. in a Using integer is only useful when there are more than one Below are two examples that demonstrate how to use the count function to:
  • display the accumulative sale count.
  • use with a HideDetail modifier to save the output for the GrantTotal row.

Example: Using Count(“saleId”)

Example output:
Each row includes the result of the Count(saleId) function and is accessed just like normal detail columns in the row.ColumnData collection. The following example includes the GrandTotal=True option in the GetRows method. This acts as a signal to save the results of all functions with the HideDetail modifier and include them as available columns in the final row output. When set, the final row RowType is “grandtotal”.

Example: Using Count(“saleId”):HideDetail with GrandTotal

Example output:
When using the GrandTotal option, the results output a final row that facilitates access to all aggregate functions that were specified with the HideDetails modifier. This becomes useful for displaying a summary of the query results.
A detail RowType will not say row.RowType=detail. Instead, then RowType of a detail row is equal to the entity name that the row represents, for example contact, project, or sale.

Continue reading