How to Use AVERAGE Function in DAX for Power BI
In Power BI, use the
AVERAGE function in DAX to calculate the mean of a numeric column. The syntax is AVERAGE(ColumnName), which returns the average value of all numbers in that column.Syntax
The AVERAGE function in DAX calculates the average (arithmetic mean) of all the numbers in a column.
- ColumnName: The column containing numeric values to average.
DAX
AVERAGE(ColumnName)
Example
This example shows how to create a measure that calculates the average sales amount from a Sales[Amount] column.
DAX
Average Sales = AVERAGE(Sales[Amount])
Output
If Sales[Amount] contains values {100, 200, 300}, the measure returns 200
Common Pitfalls
Common mistakes when using AVERAGE include:
- Using it on non-numeric columns causes errors.
- Expecting it to ignore blanks; it ignores blanks but includes zeros.
- Confusing
AVERAGEwithAVERAGEX, which works on expressions over tables.
DAX
/* Wrong: Using AVERAGE on a text column */ Average Customer = AVERAGE(Customers[Name]) /* Right: Use AVERAGE only on numeric columns */ Average Age = AVERAGE(Customers[Age])
Quick Reference
| Function | Description | Example |
|---|---|---|
| AVERAGE | Calculates average of a numeric column | AVERAGE(Sales[Amount]) |
| AVERAGEX | Calculates average of an expression over a table | AVERAGEX(Sales, Sales[Amount] * 1.1) |
| AVERAGEA | Calculates average including TRUE/FALSE as 1/0 | AVERAGEA(Survey[Response]) |
Key Takeaways
Use AVERAGE(Column) to find the mean of numeric values in a column.
AVERAGE ignores blank values but includes zeros in the calculation.
Do not use AVERAGE on text or non-numeric columns to avoid errors.
For more complex calculations, consider AVERAGEX which works on expressions.
Always check your data type before applying AVERAGE to ensure correct results.