A semantic model is the contract between the analyst and the business: it states which tables exist, how they relate, which columns are visible to report authors, and which measures are blessed for executive use. The model is also the contract with the Vertipaq engine, because every design choice translates into either a tighter or a fatter dictionary, an active or an inactive relationship, and a query plan that either short-circuits on cached aggregations or has to scan a billion-row fact table. The work of designing and implementing the model therefore sits at the centre of every other skill in the report-building craft: a clean model makes DAX simple and visuals fast, and a tangled model makes both DAX and visuals into a debugging session that never ends.
The default reference architecture for a Power BI semantic model is the star schema, named for the radial picture you draw when a single fact table sits in the middle and dimension tables fan outward. Each dimension carries the descriptive attributes that slice the fact (Product carries Category, Subcategory, Brand, Color; Customer carries Segment, Country, City; Date carries Year, Quarter, Month, Day Of Week), and each fact stores additive numeric measurements (revenue, quantity, cost, margin) plus the surrogate-key foreign keys that point at the dimensions. The star schema is the recommended choice because Vertipaq compresses each dimension column independently and because the cross-filter machinery in DAX was designed around dimension-to-fact filter propagation. Snowflake schemas, where a dimension is split across two or more tables, can be loaded, but each additional hop adds a join the engine has to evaluate at query time and increases the chance that a report author accidentally relates a measure to the wrong grain.
Building a star schema in practice begins in Power Query, where the previous chapter already produced fact tables with stable surrogate-key foreign keys and dimension tables with one row per entity. In the model view of Power BI Desktop, the analyst drags the foreign-key column from each fact table onto the primary-key column on the matching dimension table to create a single-direction one-to-many relationship. The dimension is on the "one" side and the fact is on the "many" side. The engine annotates the relationship with a cardinality, a cross-filter direction, and an active flag. Each of those properties is described later in this chapter; the immediate point is that the relationship is the only legitimate way to push a filter from a slicer on Product[Category] down to a measure that sums Sales[Amount].
// A simple measure that depends on the relationship from Product to Sales.
Total Revenue = SUM ( Sales[Amount] )
// When a Product[Category] slicer is set to "Bikes", the engine
// walks the active relationship and restricts the Sales scan to
// the rows whose ProductKey lives in the Bikes category.
Use the CALCULATE function
The CALCULATE function is the spine of the DAX language. Every aggregation function (SUM, AVERAGE, MIN, MAX, COUNTROWS, DISTINCTCOUNT) and every iterator (SUMX, AVERAGEX, RANKX, COUNTAX) reads the current filter context at evaluation time. CALCULATE is the one function whose job is to replace that filter context with new arguments, evaluate the expression in the modified context, and return the result. Conceptually it does four things in a fixed order: it copies the current filter context, applies CALCULATE modifiers (KEEPFILTERS, REMOVEFILTERS, USERELATIONSHIP, ALL, ALLEXCEPT, ALLSELECTED), evaluates explicit filter arguments, performs context transition (turning each row context into the equivalent filter context), and finally evaluates its first expression argument against the resulting context.
Most measures use CALCULATE to compute a value under a hypothetical filter. The pattern is CALCULATE ( expression, filter1, filter2, ... ) where each filter is either a Boolean column reference such as Product[Color] = "Red", a table expression returned by FILTER, KEEPFILTERS, REMOVEFILTERS, or ALL, or a CALCULATE modifier. Boolean filters are syntactic sugar: the engine rewrites Product[Color] = "Red" into FILTER ( ALL ( Product[Color] ), Product[Color] = "Red" ), which has the side effect of clearing any existing filter on Product[Color] before applying the new one. Wrapping the same filter in KEEPFILTERS instead keeps the intersection of the visual context and the new filter, which is the right choice when the report already has a slicer on the same column and the measure should respect it.
Red Product Revenue =
CALCULATE (
[Total Revenue],
Product[Color] = "Red"
)
Red Product Revenue Respecting Slicer =
CALCULATE (
[Total Revenue],
KEEPFILTERS ( Product[Color] = "Red" )
)
Context transition is the second behaviour test takers must internalize. When CALCULATE is invoked inside a row context (the implicit per-row context that exists inside an iterator like SUMX or inside a calculated column expression), it converts that row context into a filter context that pins every column of the current table to the value on the current row. This is how a measure invoked from inside SUMX sees only the row being iterated. The most frequent author mistake is to write a calculated column that calls a measure, forget that an implicit CALCULATE wraps the measure reference, and conclude that the measure is broken when in fact it has been pinned to a single fact row.
Improve performance by identifying and removing unnecessary rows and columns
A semantic model loaded into the Vertipaq columnar engine pays for every column it stores. Columns with high cardinality (millions of distinct values: timestamps with second precision, GUIDs, free-text descriptions) inflate the dictionary the engine builds for that column and dominate the model size. Two simple disciplines pay back the most: load fewer columns and lower the cardinality of the columns that remain. The first discipline lives in Power Query, where every analytical model should drop transactional columns that the model will never expose (audit timestamps, internal status flags, comment fields). The second discipline lives at the column level: a DateTime column with second precision can almost always be split into a Date column (joined to the date dimension) and a Time column (truncated to the minute), and the model immediately drops a large fraction of its dictionary.
💡 Exam Trap: A new analyst loads the full source table into Power BI because "we might need those columns later." The model balloons, refresh times double, and the report still answers exactly the same set of questions because no visual references the extra columns. The exam-correct answer is to remove the unused columns in Power Query, not to wait until production performance complaints arrive.
💡 Exam Trap: A scenario asks how to model a calculation that depends on a hypothetical change to the filter context (for example, "show the prior year's sales beside the selected period's sales in the same visual"). The instinct is to write a calculated column. The exam-correct answer is a measure that wraps a time-intelligence call in CALCULATE, because calculated columns are evaluated at refresh time against the row context and cannot respond to slicer-driven changes in the visual filter context.
⚠️ Anti-Pattern: Loading a single wide flat table that contains every dimension attribute repeated for every fact row. The model technically loads, but Vertipaq cannot dictionary-compress the repeated dimension columns as efficiently as it can compress the dimension table once, and every relationship-based filter becomes an extra equality check across a column with low compression ratio.
🎯 Scenario: A retail dashboard sums
Sales[Amount]and shows it next to a card called "Promo Sales" that should sum only rows where the promotion flag is true. The author writesPromo Sales = SUM ( Sales[Amount] )and adds a visual-level filter forSales[PromotionFlag] = TRUE. The card works, but a second visual that wants both totals in one bar chart cannot pivot the same measure two ways. The fix isPromo Sales = CALCULATE ( [Total Revenue], Sales[PromotionFlag] = TRUE ), which makes the conditional filter part of the measure itself.
📊 Limit: Vertipaq dictionaries are stored in 64 KB segments and recompressed when a column's distinct count crosses 1,024 distinct values, after which the engine switches from hash encoding to dictionary encoding. Columns that exceed about 10 million distinct values rarely compress well; treat that as the practical ceiling for any single column the model imports.
Decision Anchor: Choose a star schema with surrogate keys when the same dimension is referenced by more than one fact table or by more than one role in the same fact table. Choose a single wide flat table only for one-off ad-hoc exploration where the analyst will discard the file at the end of the session.
Reference picture: the star
The following diagram shows how a typical retail star schema lays out when Sales is the only fact table and Date, Customer, Product, and Store are the dimensions. Each relationship is single-direction from the dimension to the fact, with the dimension on the "one" side.
