Measures vs calculated columns in DAX

When to write a DAX measure and when a calculated column, how each is calculated (at query time or at refresh), what they cost in memory and speed, row context against filter context, calculated tables, and examples of each done right.

Short answer: a calculated column is calculated once per row when the model refreshes and stored in the table, like any column; use it to slice, filter or group by the result (a price band, an age group). A measure is calculated when a visual asks for it, for the filters of each cell, and stores nothing; use it for every number you aggregate (revenue, margin %, customer count). If the answer depends on what the reader has filtered, it must be a measure.

Most slow, wrong or bloated Power BI models have the same root: a calculated column where a measure belonged. A "Margin %" column per sales line sums to nonsense in a total; a measure gets it right at every level.

How do they differ?

PointCalculated columnMeasure
Calculatedat refresh, once per rowat query time, per cell of a visual
Storedyes, in memory, compressedno, only the formula
Contextrow context: the current rowfilter context: the filters on the cell
Use in slicers, axes, filtersyesno (except via field parameters or visual filters)
Responds to slicersno, fixed at refreshyes
Typical usecategories, bands, keys, flagssums, ratios, counts, comparisons
Calculated column against measure

What does each look like?

A calculated column on the Sales table, one value per row:

Line Amount = Sales[Quantity] * Sales[Unit Price]

Price Band =
SWITCH (
    TRUE (),
    Sales[Unit Price] < 50, "Under 50",
    Sales[Unit Price] < 200, "50 to 199",
    "200 and above"
)

Price Band can go on an axis or in a slicer. Measures, one value per cell of a visual:

Revenue = SUMX ( Sales, Sales[Quantity] * Sales[Unit Price] )

Margin % = DIVIDE ( [Revenue] - [Cost], [Revenue] )

Revenue does not need the Line Amount column: SUMX multiplies row by row at query time, and the model stays smaller.

Why is a ratio column wrong?

LineRevenueCostMargin % column
A1006040%
B90081010%
Total (column summed)1,00087050%
Total (measure)1,00087013%
Margin % as a column summed in a total, against a measure

The column's 40% and 10% add to 50%, or average to 25%. The true margin is 130 / 1,000 = 13%, which only a measure computes, because it divides the totals in each cell's filter context.

What do they cost?

  • Columns use memory. Every row stores the value; a high-cardinality column (a decimal per row) compresses badly and grows the model. Columns are also recalculated at every refresh.
  • Measures use CPU at query time. A heavy measure can slow a visual; a column can be faster when the logic is row by row and used in many measures.
  • Push columns upstream. A column that does not depend on other tables is often better made in Power Query or in the source, where it is computed once and compresses better.

When is a calculated column the right choice?

  • You need the result on an axis, in a slicer or a filter: bands, groups, flags ("Is Weekend").
  • You need a relationship key that does not exist in the source (a composite key).
  • The value depends on another table at row level, for example the customer's first order date stored on the customer:
First Order Date =
CALCULATE ( MIN ( Sales[Order Date] ) )

On the Customer table, CALCULATE turns the row into a filter (context transition), so each customer gets their own first date. Then "New customers by first order month" is a simple count.

What about calculated tables?

A calculated table is a whole table from a DAX expression, built at refresh: a date table from CALENDAR, a field parameter table, a disconnected table for a what-if slicer.

Date = CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2026, 12, 31 ) )

What goes wrong?

  • Ratios as columns. Percentages, averages and distinct counts per row add up wrongly; use measures.
  • Columns copying a measure's job. Line Amount as a column only to sum it later costs memory; SUMX does it at query time.
  • Expecting a column to react to slicers. It is fixed at refresh.
  • Implicit measures. Dragging a numeric column and letting Power BI sum it works, but explicit measures are needed for calculation groups, field parameters and clear naming.

Where can you check this?

Where do you start?

Look for columns in your model that hold ratios or amounts only used in sums, and turn them into measures. Row context explained shows why columns and iterators see one row at a time.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.