Sub topic 16
Incremental refresh for large tables
This chapter assumes you can build a Power Query query in Power BI Desktop and publish a dataset (semantic model) to a workspace. It also assumes you know how a scheduled refresh runs through a gateway, as covered in the earlier chapters. Here you will learn how to stop reloading an entire fact table on every refresh.
Why a full refresh stops scaling
A scheduled refresh of an Import dataset normally re-reads every row of every table. That works for a table of 200,000 rows. For a table of 400 million order lines, the same approach causes three problems:
- The refresh runs close to the timeout limit and eventually fails.
- The source database and the gateway machine carry a heavy load for data that has not changed.
- Most of the time goes to re-reading history that will never be edited.
Incremental refresh splits a table into partitions by date. After the first load, each refresh reloads only the recent partitions and leaves the older ones alone. The date range is set by a policy that you define once in Power BI Desktop.
How the pieces fit together
Incremental refresh needs four things:
- Two Power Query parameters named
RangeStartandRangeEnd. - A filter on a date/time column in the table's query that uses those parameters.
- A refresh policy on the table.
- A publish and a first refresh in the service, which creates the partitions.
The service replaces RangeStart and RangeEnd with the boundaries of each partition and runs one query per partition. In Desktop the parameters only limit the rows you see while you develop.
Step 1: Create the parameters
In Power Query Editor, choose Manage Parameters, then New Parameter, and create two parameters:
| Setting | RangeStart | RangeEnd |
|---|---|---|
| Name | `RangeStart` | `RangeEnd` |
| Type | Date/Time | Date/Time |
| Required | Yes | Yes |
| Current value | any early date, such as 2026-11-01 | any later date, such as 2026-11-08 |
The names are case-sensitive and the type must be Date/Time, not Date. The current values only matter in Desktop. Pick a narrow window so that your preview stays small.
Step 2: Filter the table
Filter the date column of your large table so that it only returns rows between the two parameters. Using the Orders query from the data source chapter:
let
Source = Sql.Database("sql01.contoso.local", "Sales"),
Orders = Source{[Schema = "dbo", Item = "Orders"]}[Data],
Filtered = Table.SelectRows(
Orders,
each [OrderDate] >= RangeStart and [OrderDate] < RangeEnd
)
in
FilteredUse the comparison operators exactly as shown. One boundary must be inclusive (>=) and the other exclusive (<). If both are inclusive, a row timestamped exactly on a partition boundary lands in two partitions and is counted twice.
The column must be of type Date/Time. If your source stores dates as integer keys such as 20261127, convert them inside the query, for example with a function that builds a date from the integer. Keep that conversion foldable, as described next.
Check that the filter folds
Query folding means Power Query translates your steps into a single native query that the source runs, here a SQL WHERE clause. This matters more for incremental refresh than for almost any other feature. If the filter does not fold, the service pulls the whole table through the gateway and filters it in the mashup engine, once for each partition. That is slower than a plain full refresh.
To check, right-click the filter step in Power Query Editor and choose View Native Query. If the option is available, the step folds, and you should see your RangeStart and RangeEnd values in a WHERE clause. If the option is greyed out, the step does not fold. Move the filter step earlier in the query, remove steps that break folding before it, or push the logic into a database view.
Not every source supports folding. Flat files such as Excel and CSV do not, so incremental refresh brings little benefit for them.
Step 3: Define the refresh policy
Close and apply the query. In the Data pane, right-click the table, choose Incremental refresh, and set the policy:
| Setting | Meaning | Example |
|---|---|---|
| Archive data starting | How far back to keep data, relative to the refresh date | 3 years |
| Incrementally refresh data starting | The recent window that is reloaded each refresh | 10 days |
| Detect data changes | Reload a partition in the window only if a change column has a new maximum | `LastModified` |
| Only refresh complete days | Skip the current, unfinished period | On |
With these values, each refresh on 2026-11-27 keeps about three years of history and reloads the last ten days. The service creates fine-grained partitions for the recent window and larger ones (months, quarters, or years) for the archive. As time passes, it merges daily partitions into larger ones and drops partitions older than the archive range.
Detect data changes
Without this option, every partition in the refresh window is reloaded every time. With it, the service asks the source for the maximum value of your change column in each partition. It compares that value with the one saved at the previous refresh and reloads the partition only if they differ.
The change column must not be the same column you filter on. Choose a column that updates whenever a row is modified, such as LastModified. Like the date filter, the maximum query should fold. A table whose change column is not maintained reliably will show stale data in partitions that are skipped.
Time zones
The service evaluates the policy against the current date in UTC. If your business day ends at a different offset, "complete days" and partition boundaries may not match your local calendar. Keep this in mind when you compare totals with the source.
Step 4: Publish and run the first refresh
Publish the dataset, map it to the gateway data source as in the data source mapping chapter, and start a refresh. The first refresh is the heaviest one because it creates every partition and loads all the history. Later refreshes touch only the refresh window.
Take note of the following points:
- The first refresh is subject to the same timeouts as any other refresh. For very large tables, it can fail before finishing. On Premium or Fabric capacities, you can publish with the policy, then process partitions in batches through the XMLA endpoint or the enhanced refresh REST API, which accepts options such as
applyRefreshPolicy. - A service dataset that has a refresh policy cannot be downloaded as a .pbix file. Keep your original file in source control, because republishing from Desktop replaces the dataset and resets its partitions.
- The partitions only appear in tools that connect through the XMLA endpoint. The Power BI service interface does not list them.
Common errors
- Parameter errors on publish or refresh. The parameters are misnamed (
rangeStart), typed as Date, or not required. Fix the name and the type. - Duplicated or missing rows at boundaries. Both comparisons are inclusive, or both are exclusive. Use
>=with<. - A refresh slower than before. The filter does not fold. Check View Native Query.
- Stale totals in old partitions. Source rows changed outside the refresh window. Widen the window, or enable Detect data changes with a reliable column.
- Failures through the gateway. The incremental queries run through the same gateway data source as a full refresh, so the credentials and the server and database names must still match exactly.
Exercise
A table has this filter: each [OrderDate] >= RangeStart and [OrderDate] <= RangeEnd. The refresh policy keeps 2 years of data and refreshes the last 7 days. After a few refreshes, a report total for one day is slightly higher than the same total in the source database. What is the likely cause, and how do you fix it?
Show answer
Both comparisons are inclusive. A row whose OrderDate equals a partition boundary (for example midnight) matches two adjacent partitions and is loaded twice. Change the upper comparison to < so only one boundary is inclusive, republish, and run a full refresh so the partitions are rebuilt.
Exercise
You enabled the policy on a CSV-based table, and each refresh now takes longer than before. Which two checks explain this?
Show answer
First, check that the filter folds with View Native Query. Flat files do not support query folding, so every partition query reads the whole file and filters it afterward. Second, check whether the table needs incremental refresh at all. For sources that cannot fold, either move the data to a database that supports folding or keep a normal full refresh.