Sub topic 1
Import, DirectQuery, and live connection: what gets refreshed
Prerequisites
This chapter assumes you know the following:
- Basic Power BI concepts: datasets (also called semantic models), reports, and workspaces.
- How to build a report in Power BI Desktop and shape data with Power Query.
- Common data sources such as SQL Server and Excel files.
Why storage mode decides what you refresh
Every table in a Power BI dataset has a storage mode. The mode controls where the data lives after you publish. It also decides whether you need a refresh schedule, a gateway, or both. Check the mode first, before you configure anything else.
The three modes
Import copies the data into the dataset. Power BI stores it in a compressed in-memory engine. Reports read from that copy, so they are fast and work even when the source is offline. The copy is a snapshot. It stays as old as the last refresh until you refresh it again.
DirectQuery keeps no copy of the data. Each time a user opens a report or changes a filter, Power BI sends a query to the source. The data is as current as the source. Performance depends on the source and the network.
Live connection points a report at an existing model. That model is either a published Power BI dataset or an Analysis Services model. The report holds no data and no model of its own. The model's owner handles refresh. With SQL Server Analysis Services (SSAS) or Azure Analysis Services, the model lives on that server.
| Mode | Data stored in Power BI | Needs scheduled refresh | Needs a gateway if the source is on-premises |
|---|---|---|---|
| Import | Yes, a full copy | Yes | Yes, for each refresh |
| DirectQuery | No | No, except for dashboard tile caches | Yes, for every query |
| Live connection | No | No, the model's owner refreshes it | Yes, for an on-premises Analysis Services model |
What a scheduled refresh does
A scheduled refresh runs the dataset's Power Query queries again and replaces the imported data. It applies only to imported tables. A refresh cannot make a DirectQuery or live connection "more current", because those modes already read the source at query time.
For DirectQuery, Power BI caches the data behind dashboard tiles. A separate setting controls how often those tiles update. It is not a dataset refresh.
A dataset can mix modes. This is called a composite model. Only the imported tables take part in a scheduled refresh. DirectQuery tables are queried live.
Worked example
A query like this one is typical of an imported table:
let
Source = Sql.Database("sql01.contoso.local", "Sales"),
Orders = Source{[Schema = "dbo", Item = "Orders"]}[Data]
in
OrdersSuppose you load it in Import mode and publish. Orders added to the database after the last refresh do not appear in reports. Now suppose you switch the same table to DirectQuery. New orders appear on the next query, with no schedule at all. The cost is a database round trip for every visual.
The server is on a private network (sql01.contoso.local). In both cases the Power BI service cannot reach it directly. Import needs a gateway for each refresh. DirectQuery needs one for every query. The next chapters cover when a gateway is required.
Common mistakes
- Looking for a refresh schedule on a DirectQuery dataset. The schedule settings are not available for it, because there is no stored copy to update.
- Assuming a live connection report has its own refresh. The report reads the model's data, so refresh the underlying model.
- Forgetting that a composite model still needs a schedule for its imported tables.
Exercise
A report has one imported table of monthly targets and one DirectQuery table of live orders. Which table does a scheduled refresh update, and why?
Show answer
The imported targets table. A scheduled refresh replaces stored copies of data, and the DirectQuery orders table has no stored copy. It is queried at the source whenever a visual needs data.
Exercise
A report uses a live connection to a published dataset. The numbers look stale. Where do you fix this?
Show answer
On the dataset the report connects to. The report has no data of its own, so its owner must refresh that dataset, or fix its refresh schedule.