Power BI / Basic: analytical and modeling foundations / Lesson 7
Calculated Columns and Measures
Choose between a stored row-level calculation and a measure evaluated in report filter context.
On this page
Lesson goals
- Describe the role of row-level calculated columns.
- Explain how a measure responds to filter context.
- Validate both calculations on a small model.
Choose the calculation grain
A calculated column computes a value for each row of a model table, while a measure is evaluated for the current report context. Decide whether the requirement is a row attribute or an aggregate that should respond to selections. Both can be useful, but their storage, evaluation, and interaction with visuals differ.
For this bounded Power BI Desktop lab, create a synthetic Sales table with Quantity and UnitPrice columns. Use two rows: quantities 2 and 1, prices 10 and 5. The DAX snippets require that model and are illustrative; the public reader does not execute them.
Calculate a row value
Create the calculated column below in Sales. Each row multiplies its own quantity and unit price. With the stated fixture, the row values are 20 and 5. Inspect the values in a table and confirm types and units before using the column in other calculations.
Line Amount = Sales[Quantity] * Sales[UnitPrice]
The expression uses the current Sales row to calculate its line amount.
Calculate a context-sensitive total
Create the measure below in the same model. SUMX evaluates the expression for Sales rows in the current filter context and sums the results. With both fixture rows visible the expected total is 25; filtering to the second row gives 5. Test the report interaction rather than assuming every visual has the same filters.
Total Sales = SUMX(Sales, Sales[Quantity] * Sales[UnitPrice])
The measure iterates the currently eligible Sales rows and sums quantity times price.
Compare behavior and cost
A column value is available as a row attribute after model processing, while a measure is computed for a queryโs context. The right choice depends on the report and model design, not a rule that one is always faster or smaller. Review storage and query performance using representative data before optimizing.
Test totals and filters
Validate both row values, the unfiltered total, and at least one filtered total against a manual calculation. Include blank or invalid quantities under an agreed policy and verify relationship filters when dimensions are added. Record the measure definition and model version so the same result can be reproduced during review.
Common errors and fixes
A calculated column is expected to change for each slicer selection.
- Why it happens
- A stored row value was confused with a measure evaluated in context.
- How to fix it
- Use a measure when the requirement is a context-sensitive aggregate.
- Prevent it next time
- Write the intended grain and interaction before implementation.
A total differs from a sum of displayed row values.
- Why it happens
- The measure is evaluated in the totalโs filter context.
- How to fix it
- Inspect the measure and context with a small table.
- Prevent it next time
- Test totals separately from individual rows.
A calculation looks plausible but uses the wrong units.
- Why it happens
- Quantity or price meaning was not defined.
- How to fix it
- Correct the source contract and recompute the fixture.
- Prevent it next time
- Document units and validate source values.
2 practice exercises
1. The lab rows have quantities 2 and 1 at prices 10 and 5. What is the unfiltered total?
Show worked solution
The row amounts are 20 and 5, so the total is 25. Filtering to the second row leaves 5 under the stated model.
2. A user wants a total that changes with a product slicer. Which calculation type should be considered?
Show worked solution
A measure is designed to evaluate under the current filter context. Verify that the product relationship and visual interactions produce the intended eligible Sales rows.
Key takeaways
- Choose calculation type based on grain and filter behavior.
- Measures are evaluated in report context.
- Validate row values and totals with a known fixture.