> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cfo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Aggregation functions

Aggregation functions combine several selected values into one result.

## sum

Returns the numeric total.

```text theme={null}
sum(Revenue[Department: ANY])
```

## average

Returns the arithmetic mean, or null when no values exist.

```text theme={null}
average(Revenue[Department: ANY])
```

Use `average` in new formulas. The older name `avg` remains accepted.

## min and max

Return the smallest or largest value, or null when no values exist.

```text theme={null}
min(Revenue[Department: ANY])
max(Revenue[Department: ANY])
```

## count

Counts non-empty values of any type. It behaves like Excel `COUNTA`, not Excel `COUNT`.

```text theme={null}
count(Orders[Department: ANY])
```

## first and last

Return the first or last value in the selected series order, or null when the series is empty.

```text theme={null}
first(Revenue[Date.Month: ANY])
last(Revenue[Date.Month: ANY])
```

## median

Returns the middle numeric value, or the midpoint of the two middle values, or null when no values exist.

```text theme={null}
median(Revenue[Department: ANY])
```

## stdev

Returns sample standard deviation. It returns null with fewer than two values.

```text theme={null}
stdev(Revenue[Date.Month: ANY])
```

Use `stdev` in new formulas. The older name `stddev` remains accepted.

## var

Returns sample variance. It returns null with fewer than two values.

```text theme={null}
var(Revenue[Date.Month: ANY])
```

Use `var` in new formulas. The older name `variance` remains accepted.
