Sub topic 8
Detecting data changes to skip unchanged partitions
This chapter assumes you have already created the RangeStart and RangeEnd parameters, filtered a table with them so the filter folds, and defined a refresh policy. It covers one optional setting on that policy: detect data changes.
The problem it solves
With a policy of "refresh the last 10 days," the service reloads all 10 daily partitions on every refresh. Often only today's rows have changed. Reloading the other nine partitions wastes source queries and refresh time.
Detect data changes lets Power BI skip partitions whose data has not changed since the last refresh.
How it works
You pick a date/time column that records when a row was last modified, such as LastUpdated. This column is separate from the column you filter with RangeStart and RangeEnd.
During a refresh, the service does the following for each partition in the incremental period:
- It runs a polling query against the source. The query returns the maximum value of the chosen column for that partition's date range.
- It compares that value with the maximum stored from the previous refresh.
- If the values match, it skips the partition. If they differ, it refreshes the partition and stores the new maximum.
Partitions in the archive period are not polled. They are never refreshed again as part of the normal schedule.
Enabling it in Power BI Desktop
- Right-click the table and choose Incremental refresh.
- Set the archive and incremental periods.
- Select Detect data changes.
- Choose the date/time column to monitor.
In the model metadata, the policy gains a polling expression. The service generates it for you from the column you chose, so you do not write it by hand.
Choosing the column
The column must change whenever a row in the partition is inserted, updated, or deleted in a way you care about. Good candidates:
- A
ModifiedDateorLastUpdatedcolumn maintained by the source system or by a trigger. - An audit timestamp written by your ETL process.
Poor candidates:
- The
OrderDatecolumn used for partitioning. A late correction to an old order does not change it, so the change is missed. - A column that is populated only on insert and never updated.
Requirements and constraints
- The polling column must be a Date/Time type, and it must exist in the source table.
- The polling query should fold to the source. If it does not fold, the service has to read the data to find the maximum, which removes the benefit.
- The column should be indexed if the table is large. An unindexed
MAXover a date range can itself be a slow scan. - Do not remove the column in Power Query, because the polling query needs it. The column does not have to be loaded into the model for the feature to work, but it must be available in the query.
When to use it
Use it when:
- The incremental period is long, for example 30 days or more, but changes are usually confined to recent rows.
- Your source reliably maintains a last-modified column.
- The source is expensive to query, so skipping partitions saves real cost.
Skip it when:
- The incremental period is short and every partition changes on each refresh.
- The source has no trustworthy modification timestamp. A wrong timestamp gives silently stale data, which is worse than a slow refresh.
Checking that it works
After the first refresh, run a second refresh without changing the source. Then connect to the dataset through the XMLA endpoint with SQL Server Management Studio, or check the refresh history details. Partitions that were skipped should show no new processing time. If every partition is reprocessed, check that the column is a Date/Time type, that the polling query folds, and that the source value actually stays the same between refreshes.
Exercise
A table is partitioned by OrderDate with a 30-day incremental period. Detect data changes is enabled and set to monitor OrderDate. A late correction changes the amount on an order from 12 days ago, but its OrderDate is unchanged. Will the refresh pick up the correction, and what should you change?
Show answer
No. The maximum OrderDate in that partition is unchanged, so the service skips it and the correction is missed. Monitor a column that changes on every update, such as LastUpdated, and make sure the source updates it whenever a row is modified.