Sub topic 5
Defining the refresh policy: archive and incremental periods
This chapter assumes you can build Import-mode queries in Power Query, and that your large table already has the RangeStart and RangeEnd parameters and a filter that folds to the source. The refresh policy is the last piece in Power BI Desktop. It tells the service how much history to keep and how much of it to reload on each refresh.
What the policy controls
A refresh policy has two time windows, both measured back from the date of the refresh.
- The archive period (the "store rows" setting) is the total span of history the table keeps. Rows older than this are dropped.
- The incremental refresh period (the "refresh rows" setting) is the most recent slice of that history. Only this slice is reloaded on each refresh.
Everything between the two boundaries is archived. Archived data is loaded once and then left alone.
Setting the policy in Power BI Desktop
- In the Data view or Model view, right-click the table and choose Incremental refresh.
- Turn on Set import and refresh ranges. This option stays unavailable until the
RangeStartandRangeEndparameters exist. - Under Archive data starting, enter a number and a unit (days, months, quarters, or years). This is the rolling window.
- Under Incrementally refresh data starting, enter a number and a unit. This is the refresh window.
- Optionally set Detect data changes and Only refresh complete periods. Later chapters cover both.
- Select Apply.
The incremental period must be shorter than the archive period. Choosing "5 years" and "10 days" gives the policy in the diagram.
Applying the policy does not load or partition any data in Desktop. Desktop keeps loading only the slice between your parameter values. The service builds the partitions after you publish.
How the settings are stored
The dialog writes a refreshPolicy object into the table's metadata. This excerpt matches the example above.
{
"refreshPolicy": {
"policyType": "basic",
"rollingWindowGranularity": "year",
"rollingWindowPeriods": 5,
"incrementalGranularity": "day",
"incrementalPeriods": 10
}
}The rollingWindow fields are the archive period. The incremental fields are the refresh period. Seeing both forms helps when you later inspect a published model through its metadata.
Choosing the values
Pick the periods from how your data behaves, not from how much you want to save.
- Set the incremental period to cover the longest delay in which old rows can still change. If late-arriving orders can be corrected for up to a week, ten days is safe. Three days would leave stale rows in the archive.
- Set the archive period to the history that reports actually need. Each extra year adds storage and a larger first refresh.
- Match the unit to the data volume. Daily refresh periods create many small partitions. A refresh window of one month with a daily unit would be a different design than one month with a monthly unit.
Rows that change outside the incremental period are not picked up. The archive is only corrected by a full refresh of a partition, which you can trigger through the XMLA endpoint (covered in a later chapter).
Common mistakes
- Wrong data type or names on the parameters. The option stays greyed out if they are not exactly
RangeStartandRangeEndwith the Date/Time type. - Incremental period longer than or equal to the archive period. The dialog reports a validation error.
- A filter that does not fold. The policy still saves, but each partition query pulls the whole table and filters it in the mining engine. The refresh gets no faster.
- Expecting Desktop to show partitions. They appear only after publishing and the first refresh in the service.
Exercise
A table records sales that can be corrected for up to 30 days after the order date. Reports need three years of history. Which archive and incremental periods would you set, and why?
Show answer
Archive 3 years, incremental 30 days or slightly more (for example 1 month). The incremental period must cover the longest window in which old rows can still change, so corrections within 30 days are reloaded. The archive covers the history reports need, and those older rows are loaded once and not refreshed again.
Exercise
You right-click a table and the "Set import and refresh ranges" option is unavailable. What do you check first?
Show answer
Check that the parameters are named exactly RangeStart and RangeEnd and have the Date/Time type. The option is unavailable until both exist with those names and that type.