Sub topic 5
Keeping Import data current: scheduled and incremental refresh
An Import table holds a copy of the source data. That copy goes stale until something reloads it. This chapter covers how scheduled refresh reloads it, why a full reload stops being practical as data grows, and how incremental refresh limits the reload to the data that changed.
It assumes you can build an Import model in Power BI Desktop, write basic Power Query steps, and publish to a workspace. It also assumes you know what the VertiPaq engine is from the earlier chapters.
What a refresh does
A refresh is a request to the Power BI service to re-run each table's Power Query (M) query against its source and replace the table's in-memory data. During a refresh, the service keeps the old data available for report queries until the new data is committed. It needs memory for both copies at once, so a large model can need roughly twice its size during a full refresh.
The steps are:
- The service connects to the source with the stored credentials. For on-premises sources it goes through a data gateway.
- Each table's M query runs and returns rows.
- VertiPaq encodes and compresses the columns.
- Relationships, calculated columns, and calculated tables are rebuilt.
- The new data replaces the old data, and cached query results are cleared.
Measures are not part of the stored data. DAX measures are evaluated at query time, so a refresh does not "refresh" them.
Scheduled refresh
Scheduled refresh runs a full refresh at times you choose. You set it in the semantic model settings in the service: pick the time zone, the times of day, and whether to email on failure.
Limits depend on the license or capacity. Check the current documentation, because Microsoft changes these numbers:
| Item | Shared capacity (Pro) | Premium or Fabric capacity |
|---|---|---|
| Scheduled refreshes per day | 8 | 48 |
| Refresh time limit | 2 hours | 5 hours |
| Refresh by API or XMLA | API call counts toward the daily limit | Higher limits, partition-level control |
Scheduled refresh has three practical problems as the model grows:
- Duration. Every row is reloaded, including years of history that never change.
- Source load. The source database runs a full-table query on every refresh.
- Failure cost. A refresh that times out after hours leaves the old data in place, so the model stays stale.
Incremental refresh addresses all three.
Incremental refresh
Incremental refresh splits a table into partitions by date. A partition is a separately processed slice of a table. After the first load, each refresh reprocesses only the recent partitions and leaves the older ones untouched.
You need three things:
- A date/time column on the table that rarely changes for a given row, such as an order date.
- Two Power Query parameters named
RangeStartandRangeEnd. - A refresh policy on the table.
Step 1: Create the reserved parameters
In Power Query, create two parameters with exactly these names. The names are case-sensitive and reserved. Both must have the type Date/Time. Set any values you like. Desktop uses them only to limit the rows it loads while you develop. The service replaces them with each partition's boundaries during refresh.
Step 2: Filter the table on the parameters
let
Source = Sql.Database("myserver.database.windows.net", "SalesDb"),
FactSales = Source{[Schema = "dbo", Item = "FactSales"]}[Data],
Filtered = Table.SelectRows(FactSales, each [OrderDate] >= RangeStart and [OrderDate] < RangeEnd)
in
FilteredUse >= on one boundary and < on the other. If you use <= on both, a row that falls exactly on a boundary lands in two partitions and is loaded twice.
If your fact table has an integer date key such as 20261127 instead of a date/time column, convert the parameters to the same format:
let
Source = Sql.Database("myserver.database.windows.net", "SalesDb"),
FactSales = Source{[Schema = "dbo", Item = "FactSales"]}[Data],
StartKey = Number.FromText(Date.ToText(DateTime.Date(RangeStart), [Format = "yyyyMMdd"])),
EndKey = Number.FromText(Date.ToText(DateTime.Date(RangeEnd), [Format = "yyyyMMdd"])),
Filtered = Table.SelectRows(FactSales, each [OrderDateKey] >= StartKey and [OrderDateKey] < EndKey)
in
FilteredStep 3: Define the policy
In Desktop, right-click the table and choose Incremental refresh. You set two windows:
- Archive data starting N periods before the refresh date. This is how much history the table keeps. Older partitions are dropped.
- Incrementally refresh data starting N periods before the refresh date. Partitions inside this window are reprocessed on every refresh.
For example, "store 5 years, refresh 10 days" keeps five years of data and reloads only the last 10 days each time.
There are three optional settings:
- Detect data changes. You pick a column, such as
LastModified. Before reprocessing a partition in the refresh window, the service checks the maximum value of that column. It skips the partition if the value has not changed since the last refresh. - Only refresh complete periods. If the refresh window is in days, the current partial day is skipped. This suits sources where today's data is not final.
- Get the latest data in real time with DirectQuery. This is available on Premium and Fabric capacity. It makes the table a hybrid table. The newest partition uses DirectQuery, and older partitions stay in memory.
What the service does
Publish the model, then run the first refresh. The service builds the partitions, one per period, and loads all of them. This first load is the slow one. Later refreshes touch only the refresh window, add new partitions as time passes, and drop partitions that fall out of the archive window.
Why query folding is a requirement in practice
The service runs your M query once per partition, with different values for RangeStart and RangeEnd. If the date filter folds, the filter becomes a WHERE clause and the source returns only that slice. If it does not fold, Power Query downloads the whole table for each partition and filters it locally. That makes incremental refresh slower than a plain full refresh.
To check, right-click the Filtered step in Power Query and look at View Native Query. If the option is greyed out, the step does not fold. Common causes are:
- A step before the filter that breaks folding, such as
Table.Bufferor a custom function. - A non-relational source such as a CSV, Excel file, or most web APIs.
- A filter on a column that was converted or computed in M instead of at the source.
Move the date filter as early in the query as you can, ideally the first step after navigation.
Common errors and gotchas
- Parameter errors. If
RangeStartorRangeEndis misspelled or has type Date or Text, the Incremental refresh option is unavailable or the policy fails. Use Date/Time and the exact names. - Republishing resets partitions. Publishing a new .pbix over an existing model replaces its partitions, so the next refresh reloads all history. For routine model changes, use the XMLA endpoint with a tool such as Tabular Editor or ALM Toolkit, which can deploy metadata without losing data (Premium and Fabric).
- No download. You cannot download a .pbix from the service once the model has an incremental refresh policy. Keep the source file under version control.
- Late-arriving changes. If a source row dated 8 months ago is corrected, a "refresh 10 days" policy never sees it. Either widen the refresh window, use a change-detection column that covers the correction, or run a full or partition-level refresh through XMLA.
- A changing date column. If a row's
OrderDatecan be edited, the row can appear in two partitions or none. Partition on a column that does not change after the row is created. - Credentials and gateway. A refresh that works in Desktop can fail in the service if the credentials are not set in the semantic model settings or the gateway data source does not match. Fix these before blaming the policy.
- Time zones. The service evaluates the partition boundaries in UTC. If your source stores local time, rows near midnight can land in the neighboring partition. This matters most with "only refresh complete periods".
Choosing between the two
| Question | Full scheduled refresh | Incremental refresh |
|---|---|---|
| Data size | Small to medium | Large fact tables |
| Source supports folding | Not required | Needed for a real benefit |
| Old rows change | Handled automatically | Only inside the refresh window |
| Setup effort | Low | Parameters, policy, a date column |
| Refresh duration | Grows with total data | Grows with the recent window |
Dimension tables are usually small and change in place, so they normally stay on a full refresh. Apply incremental refresh to the large fact tables.
Exercise
A fact table has 6 years of rows. You set the policy to store 6 years and refresh 7 days. A source system corrects the amount on an order from 3 months ago. The next scheduled refresh runs successfully, but the report still shows the old amount. Why, and name two ways to fix it?
Show answer
The order's partition is outside the 7-day refresh window, so the service does not reload it. The partition is left untouched, and only a change-detection check on partitions inside the window would otherwise apply. Fixes: widen the refresh window to cover the correction. Alternatively, refresh the affected partition directly through the XMLA endpoint on Premium or Fabric capacity, or run a full refresh. A long-term fix is to change the source process so that corrections are applied to a recent date or a modified-date column that your policy can use.