Sub topic 11
Composite models and Dual tables
This chapter assumes you know star schemas, relationships, and the basic behavior of Import and DirectQuery tables. A composite model is a semantic model whose tables use more than one storage mode. Each table has its own storage mode, so you can keep a small dimension table in Import mode and leave a large fact table in DirectQuery.
Why mix modes
Each mode has strengths. Import is fast but copies data. DirectQuery is current but depends on the source. A composite model lets you apply each where it fits:
- Import small, stable dimension tables such as Date, Product, and Customer.
- Use DirectQuery for a very large or frequently changing fact table.
- Import a pre-summarized table to answer common questions quickly (see the aggregations chapter).
Source groups and relationships
Tables that come from the same source and use the same mode form a group called an island. A relationship inside one island is a regular relationship, and the source engine can join the tables in a single query. A relationship between islands is a limited relationship (also called a weak relationship). The engine cannot push the join to one source, so it queries each side separately and joins the results in the semantic model.
Dual tables
A Dual table can act as either Import or DirectQuery, and the engine picks the best behavior for each query. It keeps a cached copy in memory, loaded at refresh time, like an Import table.
Consider an Import-mode Product dimension related to a DirectQuery Sales fact table. The relationship crosses islands, so it is limited. If you set Product to Dual, the engine treats the relationship as regular when a query also touches the DirectQuery Sales table. It can then push the join to the source as SQL. A query that uses only Product columns, such as a slicer list, is answered from the cache with no source call.
Setting the storage mode
In Power BI Desktop, open Model view, select a table, and open the Advanced section of the Properties pane. Choose Import, DirectQuery, or Dual in the Storage mode list.
Two rules apply:
- Changing a table from DirectQuery to Import is a one-way change. You can't switch it back.
- A table that is already Import can be changed to Dual, and a Dual table can be changed to DirectQuery. Check the options your version offers before you plan a switch.
Common errors
- Leaving dimensions as DirectQuery. Every slicer then queries the source. Set dimensions to Dual instead.
- Many-to-many limited relationships. These give surprising totals because there is no guaranteed key match. Use single-direction filters and verify results.
- Expecting freshness from Dual. The cached part is only as current as the last refresh. A report that mixes Dual and DirectQuery data can show dimension values that the fact table no longer matches.
- Credentials. Each source in a composite model needs its own credentials, and data from one source can be sent to another as filter values. Check your data privacy levels.
Check your understanding
Exercise
A model has an Import Date table and a DirectQuery Sales table with a one-to-many relationship. Slicer queries on Date are fine, but charts that use both tables are slow. What change would you try first, and why?
Show answer
Set the Date table to Dual. The relationship then becomes regular for queries that touch both tables, so the join can be pushed to the source as SQL instead of being combined inside the model. Slicer queries on Date still run from the in-memory cache.
Exercise
Why can you not make a table that was imported into the model back into a DirectQuery table in Power BI Desktop?
Show answer
Switching to Import is irreversible because the model holds loaded data and transformations that cannot be mapped back to a live source query.