Sub topic 14
Choosing between a column and a measure
This chapter assumes you can move around Power BI Desktop (Report, Table and Model views). It also assumes you know star-schema relationships and basic DAX such as SUM and IF. By the end, you can pick the right home for a piece of logic: a calculated column, a measure, Power Query, or the data source.
The core difference
A calculated column is evaluated row by row at refresh time. Its results are stored in the model. A measure is evaluated at query time, in the filter context of the visual that uses it. Nothing is stored except the formula.
Both can answer the same question:
Line Amount = Sales[Quantity] * Sales[Unit Price]Total Sales = SUM(Sales[Line Amount])Total Sales (no column) = SUMX(Sales, Sales[Quantity] * Sales[Unit Price])The first two use a stored column. The third needs no column, because SUMX builds a row context over Sales at query time. The third version spends no memory on Line Amount, so it is usually the better choice.
Ask three questions
Work through these in order.
- Do you need to slice, filter, group or sort by the result? Slicers, chart axes, filters and sort-by fields need a real column. A measure cannot sit on an axis or in a slicer.
Price Bandis a good example:
Price Band = IF(Product[List Price] >= 100, "High", "Standard")- Is the result a ratio, average or other non-additive value? Use a measure. A ratio stored per row gets summed or averaged with every row weighted equally, so the total is wrong. Compare these:
Margin % (column) = DIVIDE(Sales[Profit], Sales[Line Amount])Margin % = DIVIDE(SUM(Sales[Profit]), SUM(Sales[Line Amount]))The measure divides the totals for the current filter context. It is correct for one product and for the grand total.
- Does the value depend on what the user selects? Use a measure. Only a measure responds to filter context. For example,
Red Sales = CALCULATE([Total Sales], Product[Color] = "Red")changes the filter context. A column cannot react to slicers.
If none of these questions forces a column, default to a measure.
Where should the column live?
If you need a column, a calculated column is not the only place to build it. Consider these options.
| Option | Computed | Best when |
|---|---|---|
| Source-side column (SQL view or table) | In the source | Many reports share it, or the source can do it cheaply |
| Power Query column | At refresh, before loading | Simple row-level shaping that does not need other model tables |
| Calculated column (DAX) | At refresh, after loading | It needs relationships, such as `RELATED(Product[Category])`, or other model data |
Power Query and source-side columns are usually compressed better and keep the logic upstream. Use a DAX calculated column when you need the model, for example:
Product Category = RELATED(Product[Category])Cost and maintenance
Each calculated column adds memory and refresh time, because the engine stores it and recalculates it on every refresh. High-cardinality columns (many distinct values) cost the most. Measures add almost no storage, but a slow measure runs on every interaction.
Keep these habits:
- Prefer measures for numbers that you aggregate.
- Write explicit measures instead of dragging raw columns into visuals, so the logic is named and reusable.
- Remove calculated columns that no visual or relationship uses.
Exercise
A report must show overall margin percentage by product category and also let users filter by "High" or "Standard" price band. Which of these should be a column and which a measure?
Show answer
Price band is a column, because slicers need a real column to filter on. Margin percentage is a measure, because it is a ratio. Use DIVIDE(SUM(Sales[Profit]), SUM(Sales[Line Amount])) so it is correct at every level.