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

# Aggregation functions

> Count, total, and select the minimum or maximum from supplied values.

Aggregation functions work on the arguments in the formula. They do not query an entire table.

## `Count`

Counts meaningful non-null arguments.

* **Syntax:** `Count(value[, value...])`
* **Requires:** one or more values.
* **Returns:** Numeric count.
* **Best for:** counting populated choices or supplied values.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Count([Photo 1], [Photo 2], [Photo 3])
```

Blank or whitespace-only text, `false`, and `null` are not counted. Zero, non-empty text, `true`, and other populated values are counted.

## `Max`

Returns the largest non-null argument.

* **Syntax:** `Max(value[, value...])`
* **Requires:** one or more comparable values of the same type. Null values are skipped.
* **Returns:** the largest value, or `null` when every argument is null.
* **Best for:** thresholds, latest dates/timestamps, and highest measurements.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Max([Reading A], [Reading B], [Reading C])
```

## `Min`

Returns the smallest non-null argument.

* **Syntax:** `Min(value[, value...])`
* **Requires:** one or more comparable values of the same type. Null values are skipped.
* **Returns:** the smallest value, or `null` when every argument is null.
* **Best for:** earliest dates/timestamps and lowest measurements.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Min([Inspection 1], [Inspection 2], [Inspection 3])
```

## `Sum`

Adds non-null numeric values or non-null durations.

* **Syntax:** `Sum(value[, value...])`
* **Requires:** one or more numbers, or one or more durations. Do not mix numbers and durations.
* **Returns:** Numeric or Duration, matching the inputs; `null` when every argument is null.
* **Best for:** totals and combined elapsed time.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Sum([Labour Hours], [Travel Hours], [Admin Hours])
Sum(Hours(1), Minutes(30))
```
