DAX: calculated columns vs measures
Power BI · 14 questions
Short notes
Key idea
A calculated column is worked out once per row when the data loads and stored in the table. A measure is worked out when a visual asks for it, for whatever filters are active. Totals and ratios should almost always be measures.
Syntax
Line Total = Orders[Price] * Orders[Qty] -- column
Revenue = SUM(Orders[Amount]) -- measure
Orders Count = COUNTROWS(Orders)
Avg Order = DIVIDE([Revenue], [Orders Count])
Revenue X = SUMX(Orders, Orders[Price] * Orders[Qty])
Example
Avg Order = DIVIDE([Revenue], [Orders Count]) gives the right average for every city, month or customer you slice by. A column that divides per row and then gets summed would give nonsense.
Traps
- Ratios as columns add up wrongly in totals. Make them measures.
- Columns use memory for every row; too many slow the model.
- Use
DIVIDE, not/, to avoid divide-by-zero errors. - Use
SUMXwhen you need row-level maths before summing, instead of adding a column. - Refer to measures without a table name (
[Revenue]) and to columns with one (Orders[Amount]).
Want the full lesson with step-by-step examples, a project and a certificate? Power BI course, ₹120 →
Questions
5 free questions- Question 1easy
You need "Total Revenue" that changes when a user picks a city in a slicer. What should it be?
- Question 2medium
You want a slicer with "Budget, Mid, Premium" price bands. What do you need?
- Question 3hard
order_items has two rows: quantity 2 at price 100, and quantity 3 at price 10. What does this measure return?
Wrong Revenue = SUM(order_items[quantity]) * SUM(order_items[unit_price])
- Question 4medium
Why use
DIVIDE([Revenue], [Orders])instead of[Revenue] / [Orders]? - Question 5easy
What is DAX?
DAX: calculated columns vs measures
DAX: calculated columns vs measures
DAX: calculated columns vs measures
DAX: calculated columns vs measures
DAX: calculated columns vs measures
9 more questions on this topic, with hints, and tests
Sign up free for 21 days of every question and test.