# AGGREGATE Function

> Calculate sums, averages, counts, ranks and percentiles that ignore errors and nested subtotals with AGGREGATE in TX Sheet Control: function_num, options and k.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > AGGREGATE Function
- **323 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/aggregate/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/aggregate/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/aggregate/llms-full.txt

---

Calculate a sum, average, count, maximum or another aggregate of a list while ignoring error values or nested subtotals. `function_num` selects the calculation: 1 (AVERAGE), 2 (COUNT), 3 (COUNTA), 4 (MAX), 5 (MIN), 6 (PRODUCT), 7 (STDEV.S), 8 (STDEV.P), 9 (SUM), 10 (VAR.S), 11 (VAR.P), 12 (MEDIAN), 13 (MODE.SNGL), 14 (LARGE), 15 (SMALL), 16 (PERCENTILE.INC), 17 (QUARTILE.INC), 18 (PERCENTILE.EXC) or 19 (QUARTILE.EXC). `options` from 0 to 7 selects what is ignored, as in Excel: 2, 3, 6 and 7 ignore error values, and 0 to 3 ignore nested SUBTOTAL and AGGREGATE results. `ref1` is the range to aggregate; the functions 14 to 19 take their `k` (the rank, percentile or quartile) as the fourth argument, and return `#NUM!` without it. A `function_num` or `options` outside these ranges returns `#VALUE!`.

### Syntax

```text
AGGREGATE(function_num, options, ref1, k)
```

Category: Math. Minimum arguments: 3. Maximum arguments: 255.

Available for supported offline calculation.

### Examples

```text
=AGGREGATE(9,6,A1:A5)
```

With 10, 20, a `#DIV/0!` error, 40 and 50 in A1:A5, the formula returns 120: the sum of the numbers, with the error ignored (`options` 6).

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [ADDRESS Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/address/llms-full.txt)
- **Next:** [AMORDEGRC Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/amordegrc/llms-full.txt)
