Aggregate Functions

Aggregate functions perform operations on multiple values to create summary results.

Function Example Description

Avg

Avg(Sales)

Calculates the average (mean) of a numeric set of values.

Bin

Bin(UnitPrice BY ProductName)

Selects any numeric attribute from a dimension, fact table, or measure containing data values and places them into a discrete number of bins. This function is treated like a new dimension attribute for purposes such as aggregation, filtering, and drilling.

Count

Count(Products)

Determines the number of items with a non-null value.

First

First(Sales)

Selects the first non-null returned value of the expression argument. The First function operates at the most detailed level specified in your explicitly defined dimension.

Last

Last(Sales)

Selects the last non-null returned value of the expression.

Max

Max(Revenue)

Calculates the maximum value (highest numeric value) of the rows satisfying the numeric expression argument.

Median

Median(Sales)

Calculates the median (middle) value of the rows satisfying the numeric expression argument. When there are an even number of rows, the median is the mean of the two middle rows. This function always returns a double.

Min

Min(Revenue)

Calculates the minimum value (lowest numeric value) of the rows satisfying the numeric expression argument.

StdDev

StdDev(Sales) StdDev(DISTINCT Sales)

Returns the standard deviation for a set of values. The return type is always a double.

StdDev_Pop

StdDev_Pop(Sales) StdDev_Pop(DISTINCT Sales)

Returns the standard deviation for a set of values using the computational formula for population variance and standard deviation.

Sum

Sum(Revenue)

Calculates the sum obtained by adding up all values satisfying the numeric expression argument.