Appearance
Math
The Math node performs aggregate calculations on a numeric field across all input rows. It returns a single scalar value (not an array).
Configuration
| Property | Type | Default | Description |
|---|---|---|---|
operation | string | sum | The aggregation function to apply. |
field | string | -- | Required. The numeric field to aggregate. |
Operations
| Operation | Description |
|---|---|
sum | Sum of all values in the field. |
avg | Average (mean) of all values. |
min | Smallest value. |
max | Largest value. |
count | Number of rows. |
Input
Accepts an array of rows. Each row must have the specified field with a numeric value. Non-numeric values are treated as 0.
Output
Returns a single number (not an array of rows).
| Operation | Example Input | Output |
|---|---|---|
sum | [{price: 10}, {price: 20}, {price: 30}] | 60 |
avg | [{price: 10}, {price: 20}, {price: 30}] | 20 |
min | [{price: 10}, {price: 20}, {price: 30}] | 10 |
max | [{price: 10}, {price: 20}, {price: 30}] | 30 |
count | [{price: 10}, {price: 20}, {price: 30}] | 3 |
Example Use Cases
Calculate total revenue
operation: "sum"
field: "total"Show average rating
operation: "avg"
field: "rating"Find the cheapest product
operation: "min"
field: "price"Count items in a category
operation: "count"
field: "id"Dashboard statistics
Use multiple Math nodes with a Combine node to build a dashboard:
Table Query (orders) --> Math (sum, field: "total") --> Combine (var1: "revenue")
Table Query (orders) --> Math (count, field: "id") --> Combine (var2: "order_count")
Table Query (orders) --> Math (avg, field: "total") --> Combine (var3: "avg_order")
Table Query (users) --> Math (count, field: "id") --> Combine (var4: "user_count")