Sub topic 2
Measures, aggregation and the field wells
This chapter assumes you can work on the Power BI Desktop report canvas and that your data model already has tables and relationships. It also assumes you know sum, average and count. The goal is to understand how a visual turns fields into numbers. Every later chapter relies on that.
How a visual gets its numbers
A visual does not display raw rows. It groups rows by the fields you place on its axis, legend or rows. Then it calculates one number for each group. That number comes from an aggregation, which is a calculation that reduces many rows to one value, such as a sum or a count.
Two things control the result:
- Grouping fields are usually categorical or date fields. They decide how many bars, points or rows appear.
- Value fields are usually numeric. They decide how tall each bar is.
The previous chapter covered field types. This chapter covers what happens when you drop those fields into the visual.
The field wells
The field wells are the drop areas in the Build visual pane. Each well tells the visual what role a field plays. Well names differ between visuals, and they change slightly between Power BI Desktop versions. These are the common ones.
| Visual | Grouping wells | Value wells |
|---|---|---|
| Clustered column or bar | X-axis (or Y-axis for bars), Legend, Small multiples | Y-axis (or X-axis for bars) |
| Line chart | X-axis, Legend, Small multiples | Y-axis, Secondary y-axis |
| Matrix | Rows, Columns | Values |
| Table | Columns (all fields share one well) | Columns |
| Scatter | Values (detail level), Legend, Play axis | X Axis, Y Axis, Size |
| Card | None | Fields |
Two wells appear on almost every chart:
- Legend splits each group into colored series. Use a field with few distinct values.
- Tooltips adds extra values that appear on hover without changing the shape of the chart.
Where you put a field changes its meaning. If you put Sales[SalesAmount] in the Y-axis well, it is aggregated. If you put it in the X-axis well of a column chart, Power BI treats each distinct amount as a category. That produces a chart with hundreds of thin bars.
Implicit and explicit measures
A measure is a calculation that Power BI evaluates when the report is displayed, in the context of each bar, point or cell. There are two kinds.
An implicit measure appears when you drag a numeric column into a value well. Power BI applies a default aggregation, usually Sum, and shows a Σ icon next to the field. You can change it in the well's drop-down to Average, Minimum, Maximum, Count, Count (Distinct), Median and others.
An explicit measure is one you write in DAX (Data Analysis Expressions, the formula language of Power BI). You create it with Table tools > New measure and it appears in the model with a calculator icon.
Implicit measures are fast for exploration. They have limits that matter once a report is shared:
- The aggregation lives inside one visual. Two visuals can quietly use different aggregations of the same column.
- Other measures cannot refer to an implicit measure. You cannot build a year-over-year calculation on top of it.
- Numeric columns that are not quantities, such as
Year,ProductKeyor a postal code, are easy to sum by accident. - You cannot attach a number format or a description to the calculation itself.
For these reasons, define an explicit measure for every number a visual displays. A base measure for sales looks like this:
Total Sales = SUM ( Sales[SalesAmount] )Once it exists, hide the underlying SalesAmount column from Report view so report authors pick the measure. Later chapters build the prior-year, year-over-year and percent-of-total measures on top of [Total Sales]. Because they reference the measure, each of them changes automatically if you fix the base definition.
Choosing the right aggregation
Pick the aggregation from the question. The wrong one gives a plausible but wrong number.
Order Lines = COUNTROWS ( Sales )
Customers = DISTINCTCOUNT ( Sales[CustomerKey] )
Avg Order Line Value = DIVIDE ( [Total Sales], [Order Lines] )COUNTROWScounts rows in the table, here the sales lines.DISTINCTCOUNTcounts unique values. Use it when the same customer appears in many rows.DIVIDEreturns blank on a zero denominator instead of an error, so an empty month does not break the visual.
Averages deserve extra care. If you drop a precomputed AveragePrice column into a visual and let Power BI average it, you get an average of averages. Each row counts equally, whatever its quantity. Divide total sales by total quantity in a measure instead, so the result is weighted correctly:
Avg Selling Price = DIVIDE ( [Total Sales], SUM ( Sales[Quantity] ) )Some quantities cannot be added across time. A headcount or an account balance summed over twelve months is meaningless. For these, use an average, or the last value in the period. This is called a semi-additive measure, and it is a common source of misleading line charts.
Filter context: why one measure gives many answers
A measure has no fixed value. Power BI recalculates it for every bar, point or cell using the filter context, the set of filters that apply at that spot. The filter context comes from the fields in the wells, from slicers, and from the Filters pane.
Suppose [Total Sales] sits in a column chart with Product[Category] on the X-axis and a slicer set to 2025.
| Visual element | Filters applied | What `[Total Sales]` sums |
|---|---|---|
| Bar for Bikes | Category = Bikes, Year = 2025 | Sales lines for bikes in 2025 |
| Bar for Clothing | Category = Clothing, Year = 2025 | Sales lines for clothing in 2025 |
| Card with no grouping | Year = 2025 | All sales lines in 2025 |
You write the formula once and the visual supplies the context. The same measure then works in a bar chart, a line chart, a card and a matrix.
Common errors
- A bar chart with one enormous bar or hundreds of bars. A numeric field sits in the grouping well, or a high-cardinality field (one with very many distinct values), such as an order number, sits on the axis. Move it, or group it into bands first.
- A total that looks wrong in a table. The total row evaluates the measure with no row filter. It does not add up the rows above it. For averages, ratios and distinct counts, the total differs from the sum of the rows. That is correct behavior, but check it matches what the reader expects.
- Sums of a numeric key or year. Set Summarization to Don't summarize in Column tools for such columns.
- Blank instead of zero. A measure returns blank where no rows exist, and most charts then omit that category. This is usually what you want. Avoid forcing zeros with
+ 0, which fills every category and can bloat a chart.
Summary
The grouping wells decide how many marks a visual draws. The value wells decide how big each mark is. An explicit DAX measure gives you one reusable, formatted definition of that size. Filter context then recalculates it for each mark. Choosing a visual in later chapters means choosing the grouping fields and the measure together.
Exercise
A column chart shows Product[Category] on the X-axis and an average of a precomputed UnitPrice column in the Y-axis well. A colleague says the numbers look too high for categories that sell mostly cheap items in bulk. What is the likely cause, and what measure would you create to fix it?
Show answer
Power BI is averaging the UnitPrice values row by row, so a row with a quantity of 1 counts as much as a row with a quantity of 500. This is an average of averages. Create a weighted measure that divides totals: Avg Selling Price = DIVIDE ( [Total Sales], SUM ( Sales[Quantity] ) ). Put the measure in the Y-axis well in place of the implicit average.
Exercise
Why does a measure such as Customers = DISTINCTCOUNT ( Sales[CustomerKey] ) show a total in a table that is smaller than the sum of the rows above it?
Show answer
The total row evaluates the measure with no row-level filter, so each customer is counted once across the whole table. A customer who bought in two categories is counted in both category rows but only once in the total. The total is correct for distinct counts.