AggregatedExpressionFunction
Defines an AdapTableQL function that aggregates data
export interfaceProperties
| Property | Type | Description |
|---|---|---|
| category | string | Freeform Functions-menu section for Alert Aggregated / Calculated Column Aggregated editors. Omit (or use 'Aggregation') to list under Aggregation;any other string becomes its own section label. |
| cumulative | boolean | \{ currentValue: (context:AggregatedExpressionCumulativeValueContext) => any; \} | Accept a CUMULATIVE([orderColumn]) clause, e.g.MY_AGG{[notional], CUMULATIVE([tradeDate])}.- true — generic running variant: rows are visited in CUMULATIVEorder (per GROUP_BY partition when grouped), reducer accumulates,and the value recorded for each row is processAggregatedValue (orthe accumulator when absent) evaluated on the prefix so far. - object — override the per-row read with currentValue whenprocessAggregatedValue is too expensive to run per row or therunning value is not a function of the accumulator alone. Declaring the capability also makes the clause known to validation, the Expression Editor clause chips / Cumulative editor and the Query Builder. |
| description | string | What the aggregation evaluates to (outcome), shown in editor documentation. Often starts with "Returns …". |
| examples | string[] | Examples to use the Aggregated Expression Function |
| filterRow | (context:AggregatedExpressionFilterRowContext) => boolean | Optional filter which is applied to each row before the reducer is called. If the filter returns false, the row is NOT included in the aggregation. |
| initialValue | any | Mandatory Initial Value for the aggregation. May be a plain value or a factory function returning a fresh value. Use a factory when the reducer mutates its accumulator (objects, arrays, Maps, Sets) — plain object values are deep-cloned per aggregation run (and per group) for backward compatibility, which is slower. |
| inputTypes | ExpressionFunctionInputType[] | Optional argument types. |
| isAvailable | AdaptableAggregatedExpressionModule[] | ((context:ExpressionFunctionAvailabilityContext) => boolean) | Where the function is available — same semantics as standardisAvailable, but restricted to (Alert Aggregated and Calculated Column Aggregated). undefined means both aggregated expression modules. |
| prepareRowValue | (context:AggregatedExpressionPrepareRowValueContext) => number | string | boolean | Date | undefined | Called for each row AFTER the reducer() and processAggregatedValue() functions Can be used when each row has a different aggregated value (e.g. percentage = row value / aggregated value). Returns return value for each individual row (a boolean suits a boolean Calculated Column, e.g. "is in the top K") |
| processAggregatedValue | (context:AggregatedExpressionProcessAggValueContext) => any | Called AFTER the reducer() has processed all values / rows Can be used to change result of reducer based on the values array (e.g. average = aggregated value / count) |
| reducer | (context:AggregatedExpressionReducerContext) => any | Mandatory Reducer function which is called for each value(row) in the Column Data |
| returnType | AggregatedExpressionReturnType | Static result type of the aggregation. Drives the Calculated Column data type, the outer expression type check and editor documentation. 'input' = same type as the aggregated column (MIN / MAX style). Whenomitted the result type is unknown (Calculated Columns default to number). |
| signatures | string[] | Example Signatures for the Aggregated Expression Function |
| weight | boolean | Accept a WEIGHT([column]) clause, e.g.MY_VWAP{[price], WEIGHT([quantity])}. The resolved weight of thecurrent row is delivered as weightValue on the reducer,prepareRowValue and filterRow contexts (and on the cumulativecurrentValue context). |
Property Details
category
Freeform Functions-menu section for Alert Aggregated / Calculated Column
Aggregated editors. Omit (or use 'Aggregation') to list under Aggregation;
any other string becomes its own section label.
category?: string;Property Value
string
cumulative
Accept a CUMULATIVE([orderColumn]) clause, e.g.
MY_AGG{[notional], CUMULATIVE([tradeDate])}.
true— generic running variant: rows are visited inCUMULATIVEorder (perGROUP_BYpartition when grouped),reduceraccumulates, and the value recorded for each row isprocessAggregatedValue(or the accumulator when absent) evaluated on the prefix so far.- object — override the per-row read with
currentValuewhenprocessAggregatedValueis too expensive to run per row or the running value is not a function of the accumulator alone.
Declaring the capability also makes the clause known to validation, the Expression Editor clause chips / Cumulative editor and the Query Builder.
cumulative?: boolean | {
currentValue: (context: AggregatedExpressionCumulativeValueContext) => any;
};Property Value
boolean | \{ currentValue: (context:AggregatedExpressionCumulativeValueContext) => any; \}
description
What the aggregation evaluates to (outcome), shown in editor documentation. Often starts with "Returns …".
description?: string;Property Value
string
examples
Examples to use the Aggregated Expression Function
examples?: string[];Property Value
string[]
filterRow
Optional filter which is applied to each row before the reducer is called. If the filter returns false, the row is NOT included in the aggregation.
filterRow?: (context: AggregatedExpressionFilterRowContext) => boolean;Property Value
(context:AggregatedExpressionFilterRowContext) => boolean
initialValue
Mandatory Initial Value for the aggregation.
May be a plain value or a factory function returning a fresh value. Use a factory when the reducer mutates its accumulator (objects, arrays, Maps, Sets) — plain object values are deep-cloned per aggregation run (and per group) for backward compatibility, which is slower.
initialValue: any;Property Value
any
inputTypes
Optional argument types.
inputTypes?: ExpressionFunctionInputType[];Property Value
ExpressionFunctionInputType[]
isAvailable
Where the function is available — same semantics as standard
isAvailable, but restricted to
(Alert Aggregated and Calculated Column Aggregated).
undefined means both aggregated expression modules.
isAvailable?: AdaptableAggregatedExpressionModule[] | ((context: ExpressionFunctionAvailabilityContext) => boolean);Property Value
AdaptableAggregatedExpressionModule[] | ((context:ExpressionFunctionAvailabilityContext) => boolean)
prepareRowValue
Called for each row AFTER the reducer() and processAggregatedValue() functions Can be used when each row has a different aggregated value (e.g. percentage = row value / aggregated value). Returns return value for each individual row (a boolean suits a boolean Calculated Column, e.g. "is in the top K")
prepareRowValue?: (context: AggregatedExpressionPrepareRowValueContext) => number | string | boolean | Date | undefined;Property Value
(context:AggregatedExpressionPrepareRowValueContext) => number | string | boolean | Date | undefined
processAggregatedValue
Called AFTER the reducer() has processed all values / rows Can be used to change result of reducer based on the values array (e.g. average = aggregated value / count)
processAggregatedValue?: (context: AggregatedExpressionProcessAggValueContext) => any;Property Value
(context:AggregatedExpressionProcessAggValueContext) => any
reducer
Mandatory Reducer function which is called for each value(row) in the Column Data
reducer: (context: AggregatedExpressionReducerContext) => any;Property Value
(context:AggregatedExpressionReducerContext) => any
returnType
Static result type of the aggregation. Drives the Calculated Column data
type, the outer expression type check and editor documentation.
'input' = same type as the aggregated column (MIN / MAX style). When
omitted the result type is unknown (Calculated Columns default to number).
returnType?: AggregatedExpressionReturnType;Property Value
AggregatedExpressionReturnType
signatures
Example Signatures for the Aggregated Expression Function
signatures?: string[];Property Value
string[]
weight
Accept a WEIGHT([column]) clause, e.g.
MY_VWAP{[price], WEIGHT([quantity])}. The resolved weight of the
current row is delivered as weightValue on the reducer,
prepareRowValue and filterRow contexts (and on the cumulative
currentValue context).
weight?: boolean;Property Value
boolean