Observable Expressions
Summary
- Observable Expressions read change history (and time) and return a value
- The value can be a number, date, duration, or something you compare in a boolean rule
- Observable Functions always use curly braces (never parentheses)
- They compose like all other expressions, e.g. arithmetic, comparisons,
CASE, other Functions etc - Available in Alerts, Calculated Columns, Flashing Cells and Conditional Styles
Observable Expressions watch how data has changed in AG Grid over time.
They work by leveraging AdapTable's recorded cell / row history.
Why use Observable Expressions?
- Questions about time, in 1 line: ticked 10 times in 10 sec, highest price in last 5 mins, moved 2% in last minute
- Detect silence: spot a stale price or a feed that has stopped - something no single data change can tell you
- No event-handling code: no timers, buffers or subscriptions to write & maintain; AdapTable records history for you
- Use the answer anywhere: show it in a Calculated Column, style or flash a cell with it, or fire an Alert on it
- Built for live data: a natural fit for ticking prices, positions and order books
Hint
- Observable Expressions are also ideal for detecting silence or lack of changes
- e.g.
NO_CHANGES{[price], WITHIN(20s)}is true when price has been quiet for 20 seconds
Observable Expressions are used in 4 AdapTable Modules:
| Module | Typical use |
|---|---|
| Observable Alerts | Fire when a live boolean rule becomes true |
| Calculated Columns | Display a live value (e.g. highest price today) |
| Flashing Cells | Flash while an Observable Condition is true |
| Format Column Conditions | Style a cell while a live Condition is true |
Note
AG Grid keeps no cell history: it can flash a cell when it changes, but cannot say how often or how far it has moved
- A price feed updates
Last4 times a second -NVDAticks far more often than the rest, whileXOMandCVXnever tick - 4 Observable Calculated Columns show live values for each row:
Ticks (1m)-CHANGE_COUNT{[last], WITHIN(1m)}Move % (1m)-PERCENT_CHANGE{[last], WITHIN(1m)}High (5m)andLow (5m)-HIGHEST{[last], WITHIN(5m)}andLOWEST{[last], WITHIN(5m)}
- 2 Conditional Styles style the
LastColumn:- stale (grey) -
NO_CHANGES{[last], WITHIN(15s)} - at the 5 minute high (green) -
[last] = HIGHEST{[last], WITHIN(5m)}
- stale (grey) -
- An Observable Alert fires for a busy symbol -
CHANGE_COUNT{[last], WITHIN(10s)} >= 10
- Watch
XOMandCVXturn grey after 15 seconds — they never tick, soNO_CHANGESbecomes true - See the
Busy SymbolAlert fire forNVDAin the Status Bar - Click Pause Feed - after 15 seconds every row turns grey; click Resume Feed to restart it
Observable Functions
There are a large range of Observable Functions provided by AdapTable.
Caution
- Write Observable Functions with curly braces (as with Aggregations); use parentheses for Standard Functions
- e.g.
PERCENT_CHANGE([bid])is Standard function;PERCENT_CHANGE{[bid], WITHIN(1h)}is Observable function
Each Observable Function returns a value:
| Function | Description |
|---|---|
CHANGE_COUNT | How many times a cell has changed |
NO_CHANGES | True when nothing changed in the timeframe |
SINCE_CHANGE | How long ago the last change was |
CHANGED_AT | When the last change happened |
NET_CHANGE | Current value minus start-of-timeframe value |
PERCENT_CHANGE | Percent move over the timeframe |
HIGHEST | Highest value in the timeframe |
LOWEST | Lowest value in the timeframe |
PREVIOUS | Value before the last change (or n ago) |
ROW_AGE | How long ago this row was added |
ADDED_AT | When this row was added |
ROWS_ADDED | How many rows were added (grid-wide) |
ROWS_REMOVED | How many rows were removed (grid-wide) |
Hint
- You can turn an Observable into a boolean rule by using standard comparison functions
- This allows you to create Observable Alerts or Observable Conditional Styles:
// Alert if at least 3 changes to this row's price in the last 5 minutes
CHANGE_COUNT{[price], WITHIN(5m)} >
// Style cells where Price is at its highest value in the last hour
[price] = HIGHEST{[price], WITHIN(1h)}Timeframe and clock-based Expressions continually re-evaluate as time passes.
Hint
Make sure that the liveRefreshIntervalMs property in Expression Options is greater than 0 (default 1000)
CHANGE_COUNT
The CHANGE_COUNT function is most commonly used Observable function.
It returns how many times a cell has changed in a given time period.
Note
This can be either in a sliding timeframe, or since the Grid loaded
The function returns a number.
Hint
- The function evaluates per row by default; add
ALL_ROWS()to count changes of the column across all rows - Additionally, use
ANY_COL()to count changes of any column instead of a specified one
// Changes to this row's price in the last 5 minutes
CHANGE_COUNT{[price], WITHIN(5m)} // Alert / Format when the cell has moved at least 3 times in 5 minutes
CHANGE_COUNT{[price], WITHIN(5m)} >
// Grid-wide: how many times price changed (any row) in the last minute
CHANGE_COUNT{[price], WITHIN(1m), ALL_ROWS()} // Changes to any column on this row in the last minute
CHANGE_COUNT{ANY_COL(), WITHIN(1m)}NO_CHANGES
NO_CHANGES is the other most commonly used Expression Function - and it checks for silence.
The function returns a boolean — true when nothing in the watched column (or, with ANY_COL(), in any column) changed during the whole window.
Hint
Prefer NO_CHANGES over CHANGE_COUNT{…} = 0 for “has this gone quiet?” rules
The WITHIN clause sets the timeframe for the lack of changes.
Note
- The window must have fully elapsed since Grid loaded, so is false at startup and true only after full silent window
- Without
WITHIN, the value remains true while the cell has never changed
// This row's price has been quiet for 20 seconds
NO_CHANGES{[price], WITHIN(20s)} // Nothing has changed anywhere in the Grid for 10 seconds
NO_CHANGES{ANY_COL(), WITHIN(10s), ALL_ROWS()}Caution
NO_CHANGES accepts WITHIN, but not LAST_N.
SINCE_CHANGE
SINCE_CHANGE returns how long ago the cell (or, with ANY_COL(), any column) last changed, as a duration.
The value keeps growing on the clock.
Caution
The value is null until the first change since the Grid loaded
// How long since this row's price last moved
SINCE_CHANGE{[price]} // Last tick was more than 30 seconds ago
SINCE_CHANGE{[price]} > 30sHint
- For “no changes for x” rules prefer
NO_CHANGES{…} SINCE_CHANGEis preferable when you wish to use a growing clock
CHANGED_AT
CHANGED_AT returns the instant the cell (or, with ANY_COL(), any column) last changed, as a date.
Caution
The value is null until the first change since the Grid loaded
// When this row's price last moved
CHANGED_AT{[price]} // Last change was today
IS_TODAY(CHANGED_AT{[price]})NET_CHANGE
NET_CHANGE returns the current value minus the value at the start of the timeframe (or when the grid loaded).
It returns a number (positive when the cell went up).
Caution
The value is null until the cell has changed
// Net move in price over the last hour
NET_CHANGE{[price], WITHIN(1h)} // Price has risen by more than 10 in the last hour
NET_CHANGE{[price], WITHIN(1h)} > 10 // Absolute net move over the last 5 change events
ABS(NET_CHANGE{[price], LAST_N(5)})PERCENT_CHANGE
PERCENT_CHANGE tracks the percentage move over the timeframe: (current − start) / start × 100.
The function returns a number.
Caution
- This is the brace (Observable) form
- See Relative Change for the Standard Function used in Alert / Flashing Cell change rules
// Percent move of this row's price over the last hour
PERCENT_CHANGE{[price], WITHIN(1h)} // Price is up more than 5% in the last hour
PERCENT_CHANGE{[price], WITHIN(1h)} > 5HIGHEST
HIGHEST returns the highest value the cell has taken in the timeframe (or since load).
It returns the same type as the watched column (number or date).
Caution
The value is null until the cell has changed
// Highest price in the last 8 hours
HIGHEST{[price], WITHIN(8h)} // At the high of the last 8 hours
[price] = HIGHEST{[price], WITHIN(8h)} // Distance from the high of the last 20 ticks
HIGHEST{[price], LAST_N(20)} - [price]LOWEST
LOWEST returns the lowest value the cell has taken in the timeframe (or since load).
It has the same return behaviour as HIGHEST.
// Lowest price in the last 8 hours
LOWEST{[price], WITHIN(8h)} // At the low of the last 8 hours
[price] = LOWEST{[price], WITHIN(8h)}PREVIOUS
PREVIOUS returns the value the cell had before its last change (or before its last n changes).
It returns the same type as the watched column.
Caution
The value is null until enough changes have occurred
// Previous price for this row
PREVIOUS{[price]} // Move versus the previous tick (useful in Calculated Columns)
[price] - PREVIOUS{[price]}Unlike most observable functions, PREVIOUS does not take WITHIN or LAST_N.
Instead, pass a number as a "lookback" to go back more than one change:
// Higher than three changes ago
[price] > PREVIOUS{[price], 3}PREVIOUS does accept the ALL_ROWS(), TRIGGER and WHERE clauses (see Timeframes & Clauses below):
// Price before the last user edit (ignores streaming ticks)
PREVIOUS{[price], TRIGGER('edit')} // Previous price change anywhere in the grid (same value on every row)
PREVIOUS{[price], ALL_ROWS()}ROW_AGE
ROW_AGE tracks how long ago the row was added to the grid, as a duration.
The value keeps growing on the clock.
Caution
The value is null for rows already present when the grid loaded
There is no column input and no timeframe clauses.
// Age of this row
ROW_AGE{} // Row added in the last 30 seconds
ROW_AGE{} <
// Stale row — present for more than an hour
ROW_AGE{} > 1hADDED_AT
ADDED_AT returns the instant the row was added, as a date.
Caution
The value is null for rows already present when the grid loaded
// When this row was added
ADDED_AT{} // Added after a given date
ADDED_AT{} > DATE('2026-01-01') // Added today
IS_TODAY(ADDED_AT{})ROWS_ADDED
ROWS_ADDED returns how many rows were added to the grid in the timeframe (or since load).
Note
This function is always grid-scoped, so there is no need to pass ALL_ROWS() as it is not required
// Rows added in the last minute
ROWS_ADDED{WITHIN(1m)} // Burst of adds
ROWS_ADDED{WITHIN(1m)} > 10 // At least one Active row added in the last 10 seconds
ROWS_ADDED{WHERE [status] = 'Active', WITHIN(10s)} >
Hint
This function (and ROWS_REMOVED below) is often used when creating Row Change Alerts
ROWS_REMOVED
ROWS_REMOVED returns how many rows were removed from the grid in the timeframe (or since load).
// Removals in the last minute
ROWS_REMOVED{WITHIN(1m)}Like with ROWS_ADDED, this is always grid-scoped and often used in Row Change Alerts.
// Any removal in the last minute
ROWS_REMOVED{WITHIN(1m)} > 0Timeframes & Clauses
Most Observable Expression Functions accept an optional timeframe.
Hint
Omit it to mean since the grid loaded (see Change History below)
There are 2 timeframes and 4 other clauses available:
| Clause | Description |
|---|---|
WITHIN | Sliding timeframe (e.g. last 5 minutes) |
LAST_N | Sliding count timeframe (last n change events) |
ANY_COL() | Watch every column (or a listed set) instead of one |
ALL_ROWS() | Shared history across all rows (not per row) |
TRIGGER | Limit which change origins count (edit, tick, …) |
WHERE | Filter which rows / changes enter the history |
WITHIN
WITHIN provides a sliding timeframe.
Caution
- Only changes in the last duration count
- Old changes age out, so the value can change on the clock even when the grid is quiet
It is possible to use duration literals.
There are 5 literals available:
| Literal | Example |
|---|---|
| 'ms' | 250ms |
| 's' | 30s |
| 'm' | 5m |
| 'h' | 1h |
| 'd' | 1d |
Note
- A
WITHINtimeframe cannot be longer than themaxTimeframeSizeExpression Option (default 8 hours) - A longer timeframe (e.g.
WITHIN(1d)) is reported as invalid unlessmaxTimeframeSizeis raised
// Changes to this row's price in the last 5 minutes
CHANGE_COUNT{[price], WITHIN(5m)} // Highest price in the last 8 hours
HIGHEST{[price], WITHIN(8h)} // Rows added in the last 10 seconds
ROWS_ADDED{WITHIN(10s)}LAST_N
LAST_N provides a sliding count timeframe.
When this is used, only the last n change events count, however old they might be.
Caution
- The value does not expire on the clock (unlike
WITHIN) WITHINandLAST_Nare mutually exclusive on the same call
// Lowest price among the last 50 changes
LOWEST{[price], LAST_N(50)} // How many times this row's price changed in the last 20 events
CHANGE_COUNT{[price], LAST_N(20)}ALL_ROWS()
ALL_ROWS() is used when you desire one shared history across all rows (instead of one per row).
The value is the same on every row.
Note
ALL_ROWS() cannot be used with ROWS_ADDED / ROWS_REMOVED as they are always grid-scoped
// Grid-wide: how many times price changed (any row) in the last minute
CHANGE_COUNT{[price], WITHIN(1m), ALL_ROWS()} // Grid-wide net move in price over the last 15 minutes
NET_CHANGE{[price], WITHIN(15m), ALL_ROWS()}ANY_COL()
ANY_COL() watches every column on the row (or the whole Grid with ALL_ROWS()), instead of a named column.
Pass column references to limit the set: ANY_COL([bid], [ask]).
Note
ANY_COL()replaces[col]— do not use both in the same call- It is accepted by
CHANGE_COUNT,NO_CHANGES,SINCE_CHANGEandCHANGED_ATonly - Calculated Column recomputations never count
// This row is quiet across every column
NO_CHANGES{ANY_COL(), WITHIN(1m)} // The whole Grid is quiet
NO_CHANGES{ANY_COL(), WITHIN(5h), ALL_ROWS()} // Ticks on bid or ask only
CHANGE_COUNT{ANY_COL([bid], [ask]), WITHIN(1m)}TRIGGER
The TRIGGER clause limits which change origins count.
Hint
Omit it to count every change
There are 4 possible origins:
| Origin | Changes Counted |
|---|---|
'edit' | Edits made in the grid (including Smart Edit, Bulk Update and Plus / Minus) |
'tick' | Row data updated from outside the grid (e.g. streaming updates) |
'undo' | An edit being undone |
'calculated' | A Calculated Column value being recalculated |
// Only user edits
CHANGE_COUNT{[price], TRIGGER('edit')} // Only streaming ticks in the last minute
CHANGE_COUNT{[price], WITHIN(1m), TRIGGER('tick')}To count more than one origin, pass them all to the same TRIGGER:
// User edits and undos (but not streaming ticks)
CHANGE_COUNT{[price], TRIGGER('edit', 'undo')}WHERE
The WHERE clause narrows which changes (or which added / removed rows) enter the history.
Note
WHERE is always put inside braces
// Grid-wide changes to orderCost, only for one customer
CHANGE_COUNT{[orderCost] WHERE [customer] = 'TRADH', WITHIN(1h), ALL_ROWS()} >= 10 // At least one Oracle row removed in the last 10 seconds
ROWS_REMOVED{WHERE [instrument] = 'ORACLE', WITHIN(10s)} >
The clause is evaluated on the row at change time.
Durations
Observable timeframes and ROW_AGE{} use a duration type.
Compare durations to duration literals (30s, 1h) — not bare numbers:
// Correct
ROW_AGE{} > 30s
// Invalid — use 30s (or another duration literal)
// ROW_AGE{} > 30Change History
AdapTable records change history only for what an active Observable Expression is watching:
- Recording starts when the Expression becomes active - when the grid loads (for Expressions already in State) or when the Expression is created (e.g. a new Alert)
- So "since the grid loaded" really means since the Expression started watching
- Expressions that watch the same Column (with the same
WHEREandALL_ROWS()settings) share one history, so a new Expression can immediately see changes already recorded - When no Expression watches a Column any more (e.g. its Alert is deleted), that history is discarded
Caution
- Change history is held in memory only - it is not saved with AdapTable State
- When the page reloads, every Observable Expression starts again with no history
Note
How much history is kept is capped by the maxTimeframeSize and maxHistoryPerCell Expression Options (see below)
Configuring Observables
All are configured using Expression Options.
maxTimeframeSize
Default: 28800000 (~8 hours)NumbermaxHistoryPerCell
Default: 1000NumberliveRefreshIntervalMs
Default: 1000Number