Aggregate Functions
Aggregate functions operate over all rows in the current data context (a DataView). They are typically used in report expressions where a table of data is available.
When called without a condition, they process every row. When called with a condition, they only include rows where the condition evaluates to True.
MAX and MIN have a dual mode: with one argument they aggregate over rows; with two arguments they compare two values and return the larger or smaller of the two (no data context required).
AVG
AVG(Value, [Condition])
Returns the average of Value across all rows (or rows matching Condition).
| Parameter | Description |
|---|---|
Value |
Numeric expression evaluated per row |
Condition |
(optional) Boolean expression; only matching rows are included |
Returns: Double
Examples:
AVG(Quantity)
AVG(Price, Category = "Electronics")
COUNT
Count(Value, [Condition])
Returns the number of rows where Value is not null/nothing (or rows matching Condition where Value is not null).
| Parameter | Description |
|---|---|
Value |
Expression evaluated per row |
Condition |
(optional) Boolean filter |
Returns: Integer
Examples:
Count(OrderID)
Count(OrderID, Status = "Complete")
COUNTDISTINCT
CountDistinct(Value, [Condition])
Returns the number of unique non-null values of Value across matching rows.
| Parameter | Description |
|---|---|
Value |
Expression evaluated per row |
Condition |
(optional) Boolean filter |
Returns: Integer
Examples:
CountDistinct(CustomerID)
CountDistinct(Product, Region = "West")
MAX
MAX(Value)
MAX(Value, Value2)
Two modes:
- Aggregate mode (
MAX(Value)) — returns the maximum value ofValueacross all rows in the data context. Supports numeric, date, and string comparisons. - Compare mode (
MAX(Value, Value2)) — returns the larger ofValueandValue2. No data context required.
Returns: Same type as the input (Double, Date, or String)
Examples:
MAX(SaleAmount) ' largest sale across all rows
MAX(StartDate) ' latest date across all rows
MAX(x, y) ' returns whichever of x or y is larger
MAXF
MAXF(Value, [Condition])
Like MAX but always supports an optional condition filter when used in aggregate mode. With two arguments and a data context, the second argument is treated as a condition (not a comparison value).
| Parameter | Description |
|---|---|
Value |
Expression evaluated per row |
Condition |
(optional) Boolean filter expression |
Returns: Same type as input
Examples:
MAXF(SaleAmount)
MAXF(SaleAmount, Region = "North")
MIN
MIN(Value)
MIN(Value, Value2)
Two modes:
- Aggregate mode (
MIN(Value)) — returns the minimum value across all rows. - Compare mode (
MIN(Value, Value2)) — returns the smaller of two values.
Returns: Same type as input
Examples:
MIN(Price)
MIN(a, b)
MINF
MINF(Value, [Condition])
Like MIN with optional condition filter for aggregate mode.
Examples:
MINF(Price, InStock = True)
STDEV
STDEV(Value, [Condition])
Returns the sample standard deviation of Value across matching rows. Uses N-1 in the denominator (Bessel's correction).
| Parameter | Description |
|---|---|
Value |
Numeric expression |
Condition |
(optional) Boolean filter |
Returns: Double
Examples:
STDEV(Temperature)
STDEV(Score, Passed = True)
STDEVP
STDEVP(Value, [Condition])
Returns the population standard deviation of Value across matching rows. Uses N in the denominator.
Returns: Double
Examples:
STDEVP(Temperature)
SUM
SUM(Value, [Condition])
Returns the sum of Value across matching rows.
| Parameter | Description |
|---|---|
Value |
Numeric expression |
Condition |
(optional) Boolean filter |
Returns: Double
Examples:
SUM(LineTotal)
SUM(Hours, Department = "Engineering")