Sub topic 5
Keeping Import data current: scheduled and incremental refresh
This chapter assumes you can build an Import-mode model in Power BI Desktop, know what a fact table is, and can read a basic Power Query (M) query. Import mode copies source data into the VertiPaq engine. That copy goes stale, so the model needs a refresh to stay current.
What a refresh does
A refresh re-runs each table's Power Query, pulls the rows, and rebuilds the compressed in-memory columns. Reports keep using the old data until the new data is committed. A failed refresh leaves the previous data in place.
In the Power BI service, you set up a scheduled refresh on the semantic model's settings page. You choose a time zone, the times of day, and who gets failure notifications. Scheduled refresh needs a data source credential. If the source is on-premises, it also needs a data gateway. The number of daily refreshes depends on your license and capacity. Shared capacity typically allows up to 8 per day, and Premium or Fabric capacity allows up to 48.
A full refresh reloads every row of every table, every time. That is fine for small models. For a fact table with hundreds of millions of rows, it wastes time and source resources, because most of those rows never change.
Incremental refresh
Incremental refresh splits a table into date-based partitions. Each refresh reloads only the recent partitions. Older partitions stay in the model untouched. You configure it in two steps.
- Create two Power Query parameters named
RangeStartandRangeEnd. Both must be of type Date/Time. These names are reserved. Power BI fills in their values for each partition. - Filter a Date/Time column of the fact table using those 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 both are inclusive, a row that falls exactly on a boundary loads into two partitions and is counted twice.
Then, in Desktop, right-click the table and choose Incremental refresh. You set two windows:
- Archive data starting: how far back to keep data, for example 5 years.
- Incrementally refresh data starting: how recent a window to reload each time, for example the last 7 days.
After you publish, the service creates the partitions. It uses the parameter values you set only for Desktop. In the service, each partition gets its own start and end dates.
Common errors
- Filter does not fold. If the
RangeStartandRangeEndfilter is not translated to a source query, Power BI downloads the whole table for every partition and filters it locally. Right-click the filter step and check that View Native Query is available. - Wrong parameter type. Parameters that are not Date/Time are rejected.
- Filtering on a column that changes. If the filtered date moves between refreshes, the same row can land in two partitions. Use a stable column such as the creation date.
- Missing credentials or gateway. The service cannot refresh without them.
Exercise
A fact table loads with incremental refresh, but each refresh takes as long as a full load. The filter uses RangeStart and RangeEnd. What is the most likely cause, and how do you check it?
Show answer
The filter step probably does not fold to the source, so Power BI downloads all rows and filters them locally. Right-click the filter step in Power Query and check whether View Native Query is available. If it is greyed out, the step does not fold, and you should move the filter earlier or remove the transformation that breaks folding.