> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# AvgIf

The **AvgIf** function finds the average value for a column or group for entries that the condition is true.  This equals the to the sum of the values that meet the condition divided by the number of values that meet the condition.

The **AvgIf** function is an aggregate function.

Aggregate functions evaluate one or more rows of data and return a single value.

In a table element, the aggregate is calculated for each grouping. For information on how to add a grouping with an aggregate calculation to a table, see [Group columns in a table](/docs/create-and-manage-tables#group-columns-in-a-table).

In a table with no groupings, the aggregate is calculated for each row. For information on how to calculate summary statistics across all rows in a table, see [Add summary statistics to a table](/docs/create-and-manage-tables#add-summary-statistics-to-a-table).

To learn more about using aggregate functions, see [Building complex formulas with grouped data](https://www.sigmacomputing.com/resources/training-videos/table-grouping-and-functions#complex-formulas).

## Syntax

`AvgIf(field, condition)`

Function arguments:

* **field** (required) - The column to take the average of.
* **condition** (required) - The condition to test. If the condition is True, then the row will be factored into the aggregate. You can use [operators](/docs/operators-overview) in conditions.

## Example

`AvgIf([Sale], [State] = "TX")`

* Finds the average Sale value for entries where the State indicated is Texas.

`AvgIf([Sales], [Region] = "East" AND [Status] = "Complete")`

* Finds the average Sale value for entries in the "East" Region that are marked as "Complete".

## Related resources

* [Avg](/docs/avg)
* [MaxIf](/docs/maxif)
* [MinIf](/docs/minif)