Aggregation Function
Last updated
Aggregation functions are essential for summarizing data in meaningful ways when creating a measure. These functions operate on a set of values and return a single summarized result.
ReOrc supports the following aggregation functions:
SUMCalculates the total sum of a numeric field.
Example:
SUM(revenue)Returns the total revenue across all records.
COUNTCounts the number of records.
Example:
COUNT(order_id)Returns the total number of orders.
COUNT DISTINCTCounts the number of unique values in a field.
Example:
Returns the number of unique customers.
AVGComputes the average value of a numeric field.
Example:
Returns the average order amount.
MINFinds the smallest value in a field.
Example:
Returns the lowest product price.
MAXFinds the largest value in a field.
Example:
Returns the highest product price.
CUSTOMAllows users to define their own aggregation logic using formulas.
Example:
Calculates the average revenue per order.
When defining a measure, an aggregation function must be specified to determine how the data should be summarized. Below is an example of how an aggregation function is used to define a measure:
This measure calculates the total revenue by summing up all revenue values.
Last updated
COUNT_DISTINCT(customer_id)AVG(order_amount)MIN(price)MAX(price)SUM(revenue) / COUNT(order_id)measures:
- name: total_revenue
label: "Total Revenue"
type: number
aggregation: SUM
expression: "SUM(revenue)"