AggregatedExpressionFunction

View as Markdown

Defines an AdapTableQL function that aggregates data

TypeScript
export interface

Properties

PropertyTypeDescription
categorystringFreeform 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.
cumulativeboolean | \{ currentValue: (context:AggregatedExpressionCumulativeValueContext) => any; \}Accept a CUMULATIVE([orderColumn]) clause, e.g.
MY_AGG{[notional], CUMULATIVE([tradeDate])}.

- true — generic running variant: rows are visited in CUMULATIVE
order (per GROUP_BY partition when grouped), reducer accumulates,
and the value recorded for each row is processAggregatedValue (or
the accumulator when absent) evaluated on the prefix so far.
- object — override the per-row read with currentValue when
processAggregatedValue is 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.
descriptionstringWhat the aggregation evaluates to (outcome), shown in editor
documentation. Often starts with "Returns …".
examplesstring[]Examples to use the Aggregated Expression Function
filterRow(context:AggregatedExpressionFilterRowContext) => booleanOptional 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.
initialValueanyMandatory 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.
inputTypesExpressionFunctionInputType[]Optional argument types.
isAvailableAdaptableAggregatedExpressionModule[] | ((context:ExpressionFunctionAvailabilityContext) => boolean)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.
prepareRowValue(context:AggregatedExpressionPrepareRowValueContext) => number | string | boolean | Date | undefinedCalled 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) => anyCalled 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) => anyMandatory Reducer function which is called for each value(row) in the Column Data
returnTypeAggregatedExpressionReturnTypeStatic 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).
signaturesstring[]Example Signatures for the Aggregated Expression Function
weightbooleanAccept 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).

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.

TypeScript
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 in CUMULATIVE order (per GROUP_BY partition when grouped), reducer accumulates, and the value recorded for each row is processAggregatedValue (or the accumulator when absent) evaluated on the prefix so far.
  • object — override the per-row read with currentValue when processAggregatedValue is 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.

TypeScript
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 …".

TypeScript
description?: string;
Property Value

string

examples

Examples to use the Aggregated Expression Function

TypeScript
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.

TypeScript
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.

TypeScript
initialValue: any;
Property Value

any

inputTypes

Optional argument types.

TypeScript
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.

TypeScript
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")

TypeScript
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)

TypeScript
processAggregatedValue?: (context: AggregatedExpressionProcessAggValueContext) => any;
Property Value

(context:AggregatedExpressionProcessAggValueContext) => any

reducer

Mandatory Reducer function which is called for each value(row) in the Column Data

TypeScript
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).

TypeScript
returnType?: AggregatedExpressionReturnType;
Property Value

AggregatedExpressionReturnType

signatures

Example Signatures for the Aggregated Expression Function

TypeScript
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).

TypeScript
weight?: boolean;
Property Value

boolean