A measure reacts to slicers; a calculated column is frozen at refresh. Get that one distinction right and most DAX confusion disappears. These six measures cover the majority of business dashboards, and each one comes with copy-ready code and the mistake that usually breaks it.
| 1 · Total sales | SUM |
| 2 · Order count | DISTINCTCOUNT |
| 3 · Average order value | DIVIDE |
| 4 · Year over year | SAMEPERIODLASTYEAR |
| 5 · Share of total | ALLSELECTED |
| 6 · Running total | FILTER + MAX |
Both are DAX. They behave differently, and using the wrong one is the most common reason a number looks right but is not.
| Calculated column | Measure | |
|---|---|---|
| When it runs | Once, at refresh | Every time the visual renders |
| Responds to slicers | No — it is baked into the row | Yes — it recalculates in the current filter context |
| Uses memory | Yes, one value per row | No stored values |
| Typical job | Row-level attributes: price band, year, profit per line | Aggregations and ratios: revenue, margin %, YoY |
Assume a fact table Sales with columns OrderID, Date, ProductKey, RegionKey and Amount, plus a marked date table Date.
Total sales = SUM( Sales[Amount] )
The base measure. Every other measure on this page references it, which means a single change here updates all of them. Put it in a dedicated measures table rather than on the fact table, so the field list stays readable.
Usually wrong when: the total is larger than expected. Check for duplicated rows in the fact table — a duplicated order line doubles the sum. Count rows in Power Query and compare with the source.
Order count = DISTINCTCOUNT( Sales[OrderID] )
Not COUNT, and not COUNTROWS. One order can contain several lines, so counting rows counts line items. A distinct count of the order key answers "how many orders" — which is what the business means.
Average order value = DIVIDE( [Total sales], [Order count] )
Use DIVIDE rather than the / operator. DIVIDE returns blank instead of an error when the denominator is zero, which keeps an empty month from showing as an error tile. The average of a ratio is not the ratio of averages — compute it from the two measures, never from a column.
Sales YoY % =
VAR Current = [Total sales]
VAR Prior = CALCULATE( [Total sales], SAMEPERIODLASTYEAR( 'Date'[Date] ) )
RETURN DIVIDE( Current - Prior, Prior )
This only works if the model has a real date table, marked as a date table, with a continuous date column and a relationship to the fact table's date. A date column inside the fact table is not enough: SAMEPERIODLASTYEAR needs a table of dates, one row per day.
Usually wrong when: every month shows the same percentage, or the first year is blank. Both point to a missing or unmarked date table.
Share of total =
DIVIDE( [Total sales], CALCULATE( [Total sales], ALLSELECTED( 'Product'[Category] ) ) )
ALLSELECTED removes the filter from the category column but keeps every other filter, including slicers and page filters. That gives "share within what the user is currently looking at", which is almost always what people mean. Using ALL instead would ignore the slicer and show share of the whole company.
Sales running total =
CALCULATE(
[Total sales],
FILTER( ALLSELECTED( 'Date'[Date] ), 'Date'[Date] <= MAX( 'Date'[Date] ) )
)
Read it as: keep only dates up to the current row, then sum. Use ALLSELECTED so a date slicer still limits the range; ALL would run beyond the visible period.
Usually wrong when: the line resets or duplicates. The date table must have exactly one row per date, and the visual must be sorted by that date column.
Put the measure in a card with no filters. If it matches the source total, the formula is fine and the visual's filters are the problem.
Compare COUNTROWS(Sales) with the row count of the source. Duplicates inflate every SUM.
Filters flow from the one side to the many side. A dimension filtering the wrong way round silently returns unfiltered totals.
A column typed as text sums to blank. Check the column icon in the data view — Σ means numeric.
Time intelligence returns wrong or blank results if the date table is not marked, or if it has gaps.
A column reference in a visual aggregates row values; a measure aggregates in the filter context. Mixing them explains most "why is this different per row" questions.
Only for measure 4. Year over year and every other time-intelligence function need a continuous date table marked as a date table and related to the fact table. The other five work without it.
In a separate table, usually called _Measures, created with "Enter data" and left empty. It keeps measures out of the fact table, keeps the field list short, and makes it obvious which fields are calculations rather than columns.
Use DIVIDE for anything user-facing. It returns blank instead of an error when the denominator is zero or blank, so empty categories and new months do not break the visual.
Because a measure is evaluated in the total's filter context, not by adding the visible cells. That is usually correct behaviour — for example a distinct count of orders cannot be summed across months, since an order can appear in two.
Yes. Replace Sales and Date with your table names and the column names with yours. If a table name contains spaces, wrap it in single quotes: 'Sales 2026'[Amount].
Most DAX problems are model problems. If relationships are not one-to-many from dimensions to facts, no formula will stay correct under filtering.
Fact and dimension tables, relationships, and the date table these measures depend on.
Every template already has a star schema, a date table and a set of measures you can inspect.