Sub topic 2
How scheduled refresh keeps imported data current
This chapter assumes you can build a report in Power BI Desktop with Power Query, know what a dataset (semantic model) and a workspace are, and have used a source such as SQL Server or Excel. It covers the working model of scheduled refresh and the errors you will meet most often.
What a refresh does
A dataset in Import mode holds a copy of the source data inside the Power BI service. When you publish, the service stores a snapshot. The snapshot does not change when the source changes. A refresh re-runs the dataset's Power Query queries against the sources and replaces the stored data with the new result.
Scheduled refresh is the service running that process for you at times you choose. DirectQuery datasets and live connections do not store data, so they do not need it. They query the source each time a user opens or interacts with a report.
What happens during a refresh
- The service starts the refresh at the scheduled time, or when you trigger it manually.
- For each query, it finds the data source and its stored credentials. If the source is on-premises, the request goes through a gateway.
- The source runs the query and returns rows.
- The service loads the rows into the dataset and recalculates tables, columns, and relationships that depend on them.
- The service records the outcome (success or failure, start and end time) in the refresh history.
If any step fails, the refresh fails as a whole. The dataset keeps the data from the last successful refresh, so reports still show older data rather than nothing.
Prerequisites for a schedule to work
A schedule only runs when these are true:
- The dataset uses Import mode (or a composite model with imported tables).
- The data source credentials are valid and set in the dataset settings.
- If the source is on-premises, a gateway data source exists and is mapped to the dataset.
- The query's server and database names match the data source definition exactly.
For example, this query reads from a SQL Server database:
let
Source = Sql.Database("sql01.contoso.local", "Sales"),
Orders = Source{[Schema = "dbo", Item = "Orders"]}[Data]
in
OrdersThe service uses the server name sql01.contoso.local and the database Sales to find the matching gateway data source. A difference such as a short name (sql01) or a different database name stops the mapping, and the refresh fails.
Common errors
| Symptom | Likely cause |
|---|---|
| Credentials are invalid or expired | The password changed, or an OAuth token expired. Sign in again in the dataset settings. |
| Data source not found or not mapped | The query's server or database name does not match the gateway data source. |
| Refresh disabled after repeated failures | The service paused the schedule because of consecutive failures. Fix the cause, then re-enable it. |
| Data is stale but refresh shows success | The source itself was not updated, or the schedule time is earlier than the source load finishes. |
Exercise
Exercise
A report built on an Import-mode dataset shows yesterday's numbers, although the source database was updated this morning. The refresh history shows no failures. Give two possible causes.
Show answer
The schedule may not have run since the source update, for example because the refresh time is earlier than the source load, so the dataset still holds the earlier snapshot. Alternatively, the refresh ran while the source load was incomplete and loaded partial data. A manual refresh after the source load finishes confirms which one it is.