Sub topic 1
What a Measure Is and How It Differs from a Calculated Column
Prerequisites
This chapter assumes you have:
- Basic familiarity with the Power BI Desktop interface: Report view, the Fields pane, and adding visuals to a report page.
- A data model with at least one table loaded. The examples use a
Salestable with the columnsOrderID,OrderDate,ProductKey,Quantity,UnitPrice,SalesAmount, andTotalCost. - A working understanding of tables, columns, and rows.
You do not need any prior DAX. DAX (Data Analysis Expressions) is the formula language used in Power BI, Excel Power Pivot, and Analysis Services tabular models. This chapter explains the two ways DAX adds calculations to a model. The chapters that follow build the SUM, COUNTROWS, and DIVIDE measures.
Two places to put a calculation
A DAX formula can be stored in a model in two main forms:
- A calculated column is a new column added to a table. Its formula runs once for every row, and the results are stored in the model.
- A measure is a named formula that is not stored as data. Power BI evaluates it each time a visual needs a number, using whatever filters apply at that moment.
Both use the same language and often the same functions. They differ in when the formula runs, what it can see, and where its result lives. Most beginner mistakes in DAX come from choosing the wrong one, so this chapter spends its time on that difference.
Calculated columns: one value per row, stored
A calculated column is evaluated row by row. When you write a reference such as Sales[SalesAmount] inside a column formula, DAX uses the value from the current row. This is called row context: the formula is evaluated as if it were sitting on one row at a time.
Here is a calculated column that labels each order line:
Line Size = IF(Sales[SalesAmount] > 1000, "Large", "Small")For each row, DAX checks that row's SalesAmount and writes "Large" or "Small". The result behaves like any imported column:
- It is saved in the model, so it uses memory and adds to file size.
- It is calculated when data is loaded or refreshed, not when someone opens a report.
- It can be used on a slicer, on a visual axis, in a legend, or in a filter, because it holds a value for every row.
That last point is the main reason to create a calculated column. If you need to group or filter rows by something the source data does not provide, a column is the right tool. Line Size can be a slicer. A measure cannot.
Measures: one value per question, calculated on demand
A measure has no row context of its own. It answers a question such as "what is the total of SalesAmount?", and the answer depends on where the number is shown. The simplest measure in this tutorial is:
Total Sales = SUM(Sales[SalesAmount])This formula does not say which rows to add up. Power BI decides that every time the measure is calculated, based on the visual, the slicers, and the filters around it. The set of filters in effect for one calculation is the filter context. The next chapters cover filter context in detail. For now, remember these points:
- A measure is evaluated once for each cell of a visual. A matrix with 4 regions and 3 years evaluates it 12 times, plus the totals, each time with different filters.
- A measure is not stored. Only its formula is saved. The result is calculated when the report renders, and it changes when the user clicks a slicer.
- A measure must aggregate.
SUM,COUNTROWS,AVERAGE, and similar functions collapse many rows into one value.
The diagram shows where each kind of calculation runs.
The dotted line shows that stored column values can feed filter context, for example when a user selects "Large" in a slicer built on Line Size. The measure then runs against only the rows that match.
Side-by-side comparison
| Aspect | Calculated column | Measure |
|---|---|---|
| Evaluated | Once per row, at load or refresh | On demand, for each visual cell |
| Context | Row context (the current row) | Filter context (slicers, visuals, report filters) |
| Stored in the model | Yes, uses memory | No, only the formula is stored |
| Result changes with slicers | No, the value is fixed until refresh | Yes |
| Can be used as a slicer, axis, or legend | Yes | No |
| Typical content | Labels, categories, flags, row-level math | Totals, counts, ratios, averages |
| Where it appears in the Fields pane | As a column, with a column icon | With a calculator icon |
Same data, different answers
Consider a table with three order lines:
| OrderID | SalesAmount | TotalCost |
|---|---|---|
| 1001 | 1200 | 800 |
| 1002 | 400 | 300 |
| 1003 | 900 | 500 |
A calculated column can compute profit for each line:
Line Profit = Sales[SalesAmount] - Sales[TotalCost]It stores 400, 100, and 400. Now suppose someone wants the total profit for the whole report. You can sum the stored column in a measure:
Total Profit = SUM(Sales[Line Profit])This works and returns 900. You could also skip the column and compute the same result without storing anything extra, because the subtraction can be done inside an iterator function. That technique comes later. The point for now is that the column made the per-row step visible and stored it. The measure produced the number a report reader actually wants.
The distinction matters more with ratios. A margin percentage stored per row cannot be added up. If the three rows hold 33%, 25%, and 44%, then summing gives 102% and averaging gives about 34%. The correct overall margin is total profit divided by total sales, which is 900 / 2500 = 36%. Only a measure that divides two totals gets this right, because it runs after the totals are calculated:
Profit Margin = DIVIDE(SUM(Sales[Line Profit]), SUM(Sales[SalesAmount]))When this measure sits in a visual filtered to a single product, it divides that product's profit by that product's sales. In a visual with no filter, it divides the grand totals. The formula is written once, and the result is correct at every level.
Choosing between them
Use these questions in order:
- Will users need to slice, filter, group, or put it on an axis? If yes, you need a column. Create it in Power Query when you can, or as a calculated column if the logic depends on other tables in the model.
- Is the result an aggregate that should respond to filters? If yes, use a measure.
- Is it a ratio, percentage, average, or running figure? Use a measure. Never store these as columns and then sum them.
- Is it simple row-level arithmetic you will aggregate later? A column works, but check whether a measure can do it without storing the extra column.
A practical rule: columns describe rows, measures answer questions. Prefer measures for anything that gets shown as a number in a card, chart value, or table total.
Common errors and how to recognize them
Using a bare column in a measure. This formula fails:
Bad Sales = Sales[SalesAmount]A measure has no current row, so DAX cannot pick one value from a column that has many. Power BI reports an error saying that a single value for the column cannot be determined. The fix is to aggregate: SUM(Sales[SalesAmount]).
Expecting a calculated column to react to slicers. A column holds one fixed value per row. If you write a column such as Total in Column = SUM(Sales[SalesAmount]), every row shows the same grand total, because a column formula runs at refresh when no slicer has been clicked. The column does not recalculate when the user filters the report. Use a measure for anything that should respond.
Storing a ratio in a column and then summing it. As the margin example showed, the totals will be wrong. Calculate the numerator and denominator as totals and divide in a measure.
Looking for a measure on an axis or slicer. Measures appear in the Fields pane but cannot be dropped into a slicer or an axis field. If you need to slice by a computed category, make it a column.
Placing everything in the wrong table. A measure can live on any table, and its result does not depend on which table holds it. Put measures where they are easy to find. A later chapter covers organizing them in a dedicated table.
How this connects to the rest of the tutorial
The next chapters create measures in Power BI Desktop and explain filter context in more detail. After that, you will write the three foundational measures: a total with SUM, a row count with COUNTROWS, and a ratio with DIVIDE. All three are measures because each one aggregates rows and must respond when a user filters the report.
Exercise
A colleague writes Avg Price Column = AVERAGE(Sales[UnitPrice]) as a calculated column on the Sales table and adds a slicer for Region. They report that the value never changes when the slicer is clicked. Why does this happen, and what should they build instead?
Show answer
A calculated column is evaluated at data refresh, before any slicer is clicked, so every row stores the same overall average of UnitPrice. The slicer filters which rows are shown, but it does not recalculate stored column values. They should create a measure, for example Avg Price = AVERAGE(Sales[UnitPrice]), which Power BI evaluates for each visual using the current filter context, including the Region slicer.
Exercise
For each requirement, say whether you would use a calculated column or a measure: (a) a slicer that splits orders into "Weekend" and "Weekday" based on OrderDate, (b) the percentage of sales that were returned, shown in a card, (c) the number of order lines shown in a table total.
Show answer
(a) Calculated column, because a slicer needs a value stored on every row. (b) Measure, because it is a ratio that must be calculated from totals under the current filters. (c) Measure, because a count must respond to the filters in each visual cell.