Aggregate Functions
An aggregate function is a function used in data analysis that performs a calculation on a set of values and returns a single summary value. These functions extract key metrics from large datasets, such as totals, averages, maximums, and minimums. This document explains how to use the built-in aggregate functions.
BI_AVG
The BI_AVG function calculates the average of a set of values.
Syntax |
|
Parameters |
|
Definition | average |
Output | Number |
Example |
Calculates the average of [Order Amount], grouped by the dimensions in the chart. |
BI_COUNT
The BI_COUNT function returns the count of items in a group.
Syntax |
|
Parameters |
|
Definition | count |
Output | Number |
Example |
Calculates the number of orders, grouped by the dimensions in the chart. |
BI_COUNTD
The BI_COUNTD function returns the unique count of items in a group.
Syntax |
|
Parameters |
|
Definition | unique count |
Output | Number |
Example |
Calculates the unique count of [Order ID], grouped by the dimensions in the chart. |
BI_MAX
The BI_MAX function returns the maximum value in a set of values.
Syntax |
|
Parameters |
|
Definition | maximum value |
Output | Number |
Example |
Calculates the maximum value of [Order Amount], grouped by the dimensions in the chart. |
BI_MEDIAN
The BI_MEDIAN function calculates the median of a set of values.
Syntax |
|
Parameters |
|
Definition | median |
Output | Number |
Example |
Calculates the median of [Order Amount], grouped by the dimensions in the chart. |
Limitations | This function is not supported by the following data sources: MySQL, AnalyticDB for MySQL 3.0, Hologres, PostgreSQL, SQL Server, Lindorm, Elasticsearch, SLS, IBM DB2 LUW_V10, Gbase 8a, and Vertica. |
BI_MIN
The BI_MIN function returns the minimum value in a set of values.
Syntax |
|
Parameters |
|
Definition | minimum value |
Output | Number |
Example |
Calculates the minimum value of [Order Amount], grouped by the dimensions in the chart. |
BI_PERCENTILE
The BI_PERCENTILE function returns the value at a specified percentile from a given expression.
Syntax |
|
Parameters |
|
Definition | Returns the value from the given expression that corresponds to the specified percentile, |
Output | Number |
Example |
Calculates the 90th percentile of [Order Amount], grouped by the dimensions in the chart. |
Limitations | This function is not supported by the following data sources: MySQL, AnalyticDB for MySQL 3.0, SQL Server, Lindorm, Shentong, IBM DB2 LUW_V10, SLS, Gbase 8a, and Vertica. |
BI_STDEV
The BI_STDEV function calculates the sample standard deviation of a set of values.
Syntax |
|
Parameters |
|
Definition | sample standard deviation |
Output | Number |
Example |
Calculates the sample standard deviation of [Order Amount], grouped by the dimensions in the chart. |
BI_STDEVP
The BI_STDEVP function calculates the population standard deviation of a set of values.
Syntax |
|
Parameters |
|
Definition | population standard deviation |
Output | Number |
Example |
Calculates the population standard deviation of [Order Amount], grouped by the dimensions in the chart. |
BI_SUM
The BI_SUM function calculates the sum of a set of values.
Syntax |
|
Parameters |
|
Definition | sum |
Output | Number |
Example |
Calculates the sum of [Order Amount], grouped by the dimensions in the chart. |
BI_VAR
The BI_VAR function calculates the sample variance of a set of values.
Syntax |
|
Parameters |
|
Definition | sample variance |
Output | Number |
Example |
Calculates the sample variance of [Order Amount], grouped by the dimensions in the chart. |
BI_VARP
The BI_VARP function calculates the population variance of a set of values.
Syntax |
|
Parameters |
|
Definition | population variance |
Output | Number |
Example |
Calculates the population variance of [Order Amount], grouped by the dimensions in the chart. |
Limitations | This function is not supported by the following data sources: Lindorm (Wide Table Engine, Multi-model SQL) and Shentong. |