Sub topic 1
The Model Both Objects Live In
Prerequisites
Assume you know Power BI Desktop's Report, Table, and Model views. You should also understand tables, columns, relationships, and basic DAX such as SUM, IF, and column references.
The model both objects live in
A Power BI semantic model contains tables, columns, relationships, and calculations. A calculated column becomes a stored column in a table. A measure is a calculation evaluated when a visual requests a value.
For example, a Sales table might contain Quantity, Unit Price, and Profit. A Product table might describe each product. A relationship connects the tables, usually from one product to many sales rows.
Row context: evaluating one row at a time
Row context means DAX is currently evaluating one specific row. A calculated column automatically has row context, so it can read values from that row:
Line Amount = Sales[Quantity] * Sales[Unit Price]Power BI evaluates this expression for every row when the model refreshes. Each result is stored in Sales[Line Amount].
Filter context: evaluating over a filtered set of rows
Filter context is the set of filters affecting a calculation. Visuals create filter context from fields on axes, slicers, filters, and the current report page.
A measure evaluates in that context:
Total Sales = SUM(Sales[Line Amount])A card might evaluate it over all sales. A chart grouped by product evaluates it separately for each product. The same measure returns different values because the visible rows change.
Calculated columns: new columns computed row by row
Use a calculated column when the result must exist for each row or act as a field. You can use it on a slicer, axis, filter, or sort rule. It increases model storage because every result is stored.
Measures: aggregations computed in the current context
Use a measure for totals, counts, averages, ratios, and other results that should respond to report filters. Measures do not create a value for every row. They calculate when a visual queries them.
Exercise
Which object should calculate sales for the current product and date filters?
Show answer
A measure, such as Total Sales = SUM(Sales[Line Amount]).