Basic DAX Aggregation Functions
These are the most commonly used DAX functions for summarizing data. They form the foundation of most Power BI measures.
SUM()
Returns the sum of all values in a column.
Syntax: SUM(ColumnName)
Example:
Total Revenue = SUM(Sales[Revenue])
Note: SUM only works with numeric columns.
SUMX()
Evaluates an expression for each row and returns the sum. Use when you need row-level calculations before summing.
Syntax: SUMX(Table, Expression)
Example:
Total Sales = SUMX(Sales, Sales[Quantity] * Sales[UnitPrice])
COUNT() and COUNTA()
| Function | Description |
|---|---|
COUNT() | Counts rows with numeric values (ignores blanks and text) |
COUNTA() | Counts rows with any non-blank value (numbers + text) |
COUNTBLANK() | Counts blank/empty rows |
COUNTROWS() | Counts all rows in a table |
DISTINCTCOUNT() | Counts unique values in a column |
Examples:
Order Count = COUNTROWS(Sales)
Unique Customers = DISTINCTCOUNT(Sales[CustomerID])
AVERAGE() and AVERAGEX()
Returns the arithmetic mean of values.
Syntax: AVERAGE(ColumnName)
Examples:
Avg Order Value = AVERAGE(Sales[Amount])
Avg Revenue Per Product = AVERAGEX(Products, [Total Revenue])
MIN() and MAX()
Return the smallest and largest values respectively.
Syntax: MIN(ColumnName) / MAX(ColumnName)
Examples:
Lowest Price = MIN(Products[Price])
Highest Sale = MAX(Sales[Amount])
With Two Arguments (Scalar Comparison):
Lower Value = MIN(Sales[Budget], Sales[Actual])
Quick Reference Table
| Function | Purpose | Example |
|---|---|---|
SUM() | Total of a column | SUM(Sales[Amount]) |
SUMX() | Row-by-row sum | SUMX(Sales, [Qty] * [Price]) |
COUNT() | Count numeric values | COUNT(Sales[OrderID]) |
COUNTA() | Count non-blank values | COUNTA(Sales[Notes]) |
COUNTROWS() | Count all rows | COUNTROWS(Sales) |
DISTINCTCOUNT() | Count unique values | DISTINCTCOUNT(Sales[CustomerID]) |
AVERAGE() | Mean value | AVERAGE(Sales[Amount]) |
MIN() | Minimum value | MIN(Sales[Amount]) |
MAX() | Maximum value | MAX(Sales[Amount]) |