# AVG

### Description

`AVG` takes all the values you provide in between a set of brackets, each separated by a comma, and gives you their average.

`AVG` can also return the average of values that are produced by another function.

### Examples

```
p is Person
AVG(p.base_fee, p.transaction_fee, p.report_fee)
```

This [expression](/rule-language/expressions.md) calculates the average of the base fee, the transaction fee, and the report fee regarding a person in a [case](/guides/glossary/case.md).

```
AVG(
    get_properties_from_instances(
        instances(AccountHolder), personal_income
    )
)
```

This expression works in a couple of steps to bring you the result:

* `AVG( .... )` is the overarching function, of which you want the result. In between its brackets sits another function.
* `get_properties_from_instances(.......)` is the function inside the `AVG` brackets, which goes and fetches the property of the instances you specify.
* `instances(AccountHolder, personal_income)` returns the personal income of all the accountholders.
* These three combined, give you the average of the personal incomes for all the account holders in the case.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.atfinity.io/rule-language/operators/mathematical-operators/avg.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
