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. It also assumes you know the difference between a dataset (also called a semantic model), a report, and a workspace. You should know the three storage modes from the previous chapter. Gateways come in the next chapters, so here we only note where one will be needed.
Why imported data goes stale
A dataset in Import mode holds a copy of the source data. When you publish from Power BI Desktop, the service stores that copy in a compressed, in-memory columnar format. Report visuals query the copy and never contact the source. Reports load quickly, but the copy is a snapshot taken at the last load.
Refreshing the data in Desktop only updates the file on your computer. The published dataset in the service keeps its old copy until something refreshes it there. Scheduled refresh is the service feature that does this on a timetable, with no one at a keyboard.
| Storage mode | Holds a copy of the data? | What scheduled refresh does |
|---|---|---|
| Import | Yes | Reloads the copy from the sources |
| DirectQuery | No | Does not reload data, because every query goes to the source. It only refreshes cached dashboard tiles. |
| Live connection | No | Not applicable. The model lives in Analysis Services or another published dataset. |
| Composite | Partly | Reloads the imported tables only |
What a refresh actually does
A refresh re-runs the Power Query queries stored in the dataset. For each table, the service does the following:
- Connects to the source with the stored credentials.
- Runs the query, including every transformation step.
- Compresses the result and builds the table's dictionaries, relationships, and calculated columns.
- Replaces the old table contents with the new ones.
Consider this query from a published dataset:
let
Source = Sql.Database("sql01.contoso.local", "Sales"),
Orders = Source{[Schema = "dbo", Item = "Orders"]}[Data]
in
OrdersEach refresh runs this query again and loads whatever dbo.Orders contains at that moment. The server and database names in the query identify the data source. The service uses them to find the stored credentials. If the source is on-premises, they also tell the service which gateway data source to use.
Four details of this process affect how you design and debug a dataset:
- Full reload by default. Unless you configure incremental refresh (covered in a later chapter), every table in the model is reloaded in full. A table of 200 million rows is read from the source again on each refresh, even if only 1,000 rows changed.
- Old data stays available while the new data loads. The service keeps the existing copy so reports can keep answering queries. It swaps in the new data when the load finishes. If the refresh fails, the old data stays in place. A failed refresh therefore leaves stale data rather than an empty report. This also means the dataset needs enough memory to hold both copies during the load, which matters on small capacities.
- Calculations are rebuilt. Calculated columns, calculated tables, and relationships are recomputed after the load. DAX measures are not stored, so they simply see the new data.
- Refresh can be turned off per query. In Desktop, a query with "Include in report refresh" cleared is skipped. This is useful for a static lookup table, and it is a common cause of "why didn't this table update?"
The refresh lifecycle
The next diagram follows one scheduled refresh from trigger to updated report.
The scheduler works as a queue, not a stopwatch. A refresh set for 07:00 may start a few minutes later, depending on load on the service or capacity. Do not build processes that assume the data is ready at exactly 07:00.
What the schedule needs
A scheduled refresh uses three settings, which are configured in later chapters:
- Credentials. The service uses the credentials stored on the dataset, not those of the person viewing the report or the person who clicked publish. If the credentials are wrong or expired, the refresh fails.
- A route to the data. Cloud sources such as Azure SQL Database can be reached directly. A source inside your network needs an on-premises data gateway.
- A schedule. This is the days, the times, and the time zone. It also includes the notification setting for failures.
Here is a schedule definition in the form the REST API accepts. Later chapters cover the API itself, so for now read it as a summary of what a schedule contains:
{
"value": {
"enabled": true,
"days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"times": ["07:00", "13:00"],
"localTimeZoneId": "UTC",
"notifyOption": "MailOnFailure"
}
}This schedule refreshes the dataset twice on each weekday, and the dataset owner gets an email if a refresh fails.
Limits that shape the design
The next chapters cover the exact figures, but you should know the main constraints now.
- Daily frequency is capped. Shared capacity allows up to 8 scheduled refreshes per day. Premium and Premium Per User capacities allow up to 48. If the business needs data fresher than that, scheduled refresh on Import mode is the wrong tool. Consider DirectQuery, a hybrid table, or an API-triggered refresh.
- Each refresh has a time limit. Shared capacity stops a refresh after 2 hours. Premium capacity allows up to 5 hours. A refresh that reloads everything on a large model can hit this limit.
- Refreshes pause themselves. The service disables a schedule after several consecutive failures. It also disables it if nobody has viewed the dataset's reports or dashboards for two months. This surprises teams who set up a monthly report and come back to find the schedule off.
Common errors at this stage
- Expecting a Desktop refresh to update the service. Refreshing in Desktop changes your local file only. You must republish or let the service refresh.
- Expecting DirectQuery to need a data reload. DirectQuery data is current at query time. A scheduled refresh on a DirectQuery-only dataset refreshes only the dashboard tile caches, not the data.
- Credentials that expire. Sources that use OAuth sign-in, such as SharePoint Online or Azure sources, issue tokens that expire. When a token expires, the refresh fails until someone signs in again on the dataset settings page.
- Query changes that break the stored mapping. Changing the server or database name in a query makes the service treat it as a new data source. The old credentials and gateway mapping no longer apply.
- Sources the service cannot resolve before running. A query that builds its source address from another query's output (a dynamic data source) often cannot be refreshed in the service, because the service cannot determine the source ahead of time.
Exercise
A team publishes a report whose dataset is in Import mode, built on an Orders table in SQL Server. A colleague adds new orders to the table at 09:00. A scheduled refresh is set for 07:00 and 13:00 on weekdays. At 11:00 a manager asks why the report does not show the 09:00 orders. Then the 13:00 refresh fails because the stored password has expired. What does the report show at 14:00, and why?
Show answer
At 14:00 the report still shows the data from the 07:00 refresh, and the 09:00 orders are missing. Import mode reads from a stored copy, so the report cannot see changes in the source until a refresh loads them. The 13:00 refresh failed, and a failed refresh does not replace the copy. The old data stays in place, and the refresh history will show the failure. Once someone updates the credentials, the next successful refresh (or an on-demand one) loads the 09:00 orders.
Exercise
A dataset has two tables. One is a large Sales table in Import mode. The other is a small Region lookup table that never changes, and its query has "Include in report refresh" cleared. What happens to each table when the scheduled refresh runs, and what is the risk of the Region setting?
Show answer
The Sales table is fully reloaded from its source. The Region table is skipped and keeps the data from the last time it loaded. This saves time on every refresh. The risk is that if the Region data ever does change, the service will not pick up the change until someone re-enables the setting or republishes the dataset. The usual symptom is new region codes that show up as blanks in visuals.