Aggregate Functions

Updated at:

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

BI_AVG(number)

Parameters

number: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

average

Output

Number

Example

BI_AVG([Order Amount])

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

BI_COUNT(expression)

Parameters

expression: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

count

Output

Number

Example

BI_COUNT([Order ID])

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

BI_COUNTD(expression)

Parameters

expression: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

unique count

Output

Number

Example

BI_COUNTD([Order ID])

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

BI_MAX(expression)

Parameters

expression: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

maximum value

Output

Number

Example

BI_MAX([Order Amount])

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

BI_MEDIAN(number)

Parameters

number: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

median

Output

Number

Example

BI_MEDIAN([Order Amount])

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

BI_MIN(expression)

Parameters

expression: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

minimum value

Output

Number

Example

BI_MIN([Order Amount])

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

BI_PERCENTILE(expression, number)

Parameters

  • expression: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

  • number: A numeric constant between 0 and 1.

Definition

Returns the value from the given expression that corresponds to the specified percentile, <number>.

Output

Number

Example

BI_PERCENTILE([Order Amount], 0.9)

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

BI_STDEV(number)

Parameters

number: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

sample standard deviation

Output

Number

Example

BI_STDEV([Order Amount])

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

BI_STDEVP(number)

Parameters

number: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

population standard deviation

Output

Number

Example

BI_STDEVP([Order Amount])

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

BI_SUM(number)

Parameters

number: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

sum

Output

Number

Example

BI_SUM([Order Amount])

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

BI_VAR(number)

Parameters

number: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

sample variance

Output

Number

Example

BI_VAR([Order Amount])

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

BI_VARP(number)

Parameters

number: The argument must be a non-aggregated value, such as a dimension, a measure, or a calculated field.

Definition

population variance

Output

Number

Example

BI_VARP([Order Amount])

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.