Aggregation Alerts

View as Markdown

Summary

  • Aggregation Alerts can use Aggregation Boolean Expressions
  • These will evaluate using multiple rows and fire if the return value is true

Alerts in AdapTable can fire as the result of an Aggregation Expressions.

This is a special type of Expression which runs against aggregated data and returns a true / false value.

For instance to define an Alert which fires when the total of a 'PnL' column is > 50M:

 // Is the sum of all PnL values over 5M
 SUM{[PnL]} > '50M'

Aggregation Functions

Currently 5 Aggregation Functions are supported:

  • SUM
  • MIN
  • MAX
  • AVG
  • COUNT

Caution

Aggregation Expressions require the Alert to have a Scope of All (i.e. the whole row)

Find Out More

With the Server-Side Row Model, the client may not have every row required for the aggregation — see Displaying Alerts and Server Evaluation.

Find Out More

The AdapTableQL Guide provides full details on writing Aggregation Expressions

WHERE Clause

Aggregation Alerts often have a WHERE clause which limits which rows are included in the evaluation.

For instance to define the Alert above, but only in rows with a Dollar Currency we would write:

 // Are all PnL values in rows with Dollar Currency over 5M
 SUM{[PnL]} > '50M' WHERE [Currency] = 'USD'
Alerts: Aggregated Expressions
Fork
  • This demo contains 4 Alerts that fire when an Aggregated Boolean Expression is triggered
    • Info Alert if the lowest Github Watchers value is under 50
    • Success Alert when the total of all the Github Stars rows is over 1.1 million
    • Warning Alert when the total of all Open Issues - only for rows where Language is JavaScript - is over 6,000
    • Error Alert when the count of all Language is 3 or greater where value is 'HTML'
Try It Out
  • In the first row change the value of:
    • Github Watchers column to 45 and see the Info Alert be fired
    • Github Stars column to 279429 and see the Success Alert be fired
    • Open Issues column to 1220 and see the Warning Alert be fired (because Language in first row is "JavaScript")
    • Language column to HTML and see the Error Alert be fired (because we now have 3 values with HTML)
Loading demo…
Developer Guide

Providing Aggregation Alerts in Initial State

const initialState: InitialState = {
  Alert: {
    AlertDefinitions: [
      {
        Name: 'alert-min-watchers',
        MessageType: 'Info',
        Scope: {
          All: true,
        },
        Rule: 'MIN{[github_watchers]} < 50',
        AlertProperties: {
          DisplayNotification: true,
          LogToConsole: true,
        },
      },
      {
        Name: 'alert-js-open-issues',
        MessageType: 'Warning',
        Scope: {
          All: true,
        },
        Rule: "SUM{[open_issues_count]} > '6k' WHERE [language] = 'JavaScript'",
        AlertProperties: {
          DisplayNotification: true,
          HighlightCell: true,
        },
      },
    ],
  },
};
1
Set Scope to All

Aggregation rules evaluate across the grid (or a WHERE subset). Use Scope: { All: true }.

2
Write an aggregation boolean Rule

Use SUM, MIN, MAX, AVG, or COUNT with curly-brace syntax; optional WHERE limits rows in the aggregation.