DAX Aggregation: SUM, AVERAGE, COUNT

2026年7月10日

Aggregation is the base layer

Every measure starts as an aggregation: sum a column, count rows, average a value. Get the aggregation right and most analysis follows; get it wrong and no visual fixes it.

SUM and SUMX

SUM(Sales[Amount]) adds one column. It is the right choice when the value already exists per row.

SUMX(Sales, Sales[Qty] * Sales[Price]) multiplies row by row, then sums. Use it when the value must be computed per row first.

The trap: SUM(Sales[Qty]) * SUM(Sales[Price]) is not the same as the SUMX version. The first multiplies totals, the second sums products.

AVERAGE and AVERAGEX

AVERAGE averages a column. AVERAGEX averages an expression per row.

A common business mistake: averaging already-averaged values. If the source has monthly averages, averaging them again weights every month equally regardless of volume. Recompute from the base numbers instead.

COUNTROWS, COUNT and DISTINCTCOUNT

  • COUNTROWS(Sales) counts rows, the safest count in a fact table
  • COUNT(Sales[Amount]) counts non-blank values in a column
  • DISTINCTCOUNT(Sales[OrderId]) counts unique orders, the standard for order volume

COUNTROWS over a dimension counts entities; over a fact table it counts transactions. Be explicit about which you mean.

MIN and MAX

Beyond ranges, MIN and MAX are useful for finding the first and last date in a period:

First Sale Date = MIN( Sales[Date] )
Last Sale Date = MAX( Sales[Date] )

They also help build dynamic titles: "data through 31 March".

Filter context decides everything

The same SUM(Sales[Amount]) returns a different number on a card, in a category bar chart and under a year slicer. Aggregation functions do not ignore filters unless you tell them to with CALCULATE and ALL.

Text and boolean aggregation

CONCATENATEX joins text values; COUNTROWS(FILTER(...)) counts conditions. Both are aggregations in the broader sense and belong to the same mental model.

Summary

Pick the aggregation that matches the business definition: sum for amounts, distinct count for entities, row count for transactions. Then let filter context do the slicing.

Related guides