About incremental refresh
Incremental refresh in Power BI divides a table into date ranges called partitions. You choose how much history to keep and how much recent data to reload on each refresh. For example, you can keep one year of data and reload only the last seven days. The first refresh loads the full year; later refreshes reload the recent days and keep the older data. This reduces download time and the risk of timeouts.Before you start
- Make sure the endpoint you want to fetch data from supports timestamp-based filtering.
- Your queries must return the same column names and data types, even when a date range contains no rows.
- All date ranges in an incrementally refreshed table must read from the same data source.
Set up incremental refresh
1
Create parameters
Create two Power Query parameters named
RangeStart and RangeEnd of type datetime.2
Apply parameter filters
Use these parameters to filter data. The parameters can be set to any date range.
3
Configure incremental refresh policy
Configure incremental refresh policy in Power BI Desktop.
4
Publish the model
Publish the model to Power BI Service.
Utility functions
Power BI suppliesRangeStart and RangeEnd as plain datetime values that represent UTC. Since CDF endpoints expect timestamps in specific formats, convert them to the format each request type expects:
- GetCDF/PostCDF: Normal GET/POST requests to the Cognite APIs expect timestamps in milliseconds since epoch (UTC).
- GraphQL: Data modeling GraphQL requests expect timestamps in ISO 8601 string format.
-
ODataCDF: OData requests expect timestamps in
datetimezoneformat for column filtering.
By default, refresh operations in the Power BI service determine the refresh window in UTC. If you configure a non-UTC time zone under Refresh,
RangeStart and RangeEnd follow that time zone instead, and these functions no longer match CDF. Keep the default to avoid the mismatch. See Configure incremental refresh.ConvertDateTimeToMs
Convert DateTime to milliseconds since epoch
ConvertDateTimeToIso
Convert DateTime to ISO 8601 text representation
ConvertDateTimeToDateTimeZone
Convert DateTime to DateTimeZone
EnforceSchema
TheEnforceSchema function ensures that the output table has a consistent schema, even when the API response is empty. This function takes an input table and a list of expected column names, and returns a table with the specified columns. If any of the expected columns are missing in the input table, they’re added with null values.
Enforce schema for a table
ColumnNamesToText
TheColumnNamesToText function generates a list of column names in a format that can be used in the EnforceSchema function. You can use it once with the response from the GetCDF, PostCDF, or GraphQL functions (when the current filter returns at least one entry) to create a list of column names that are returned by the API. This list can be used in the EnforceSchema function to ensure that the schema is consistent even when no data is returned.
Convert column names to text
EnforceSchema preserves existing column types and adds missing columns with null values. Apply explicit types after it, as shown below, so empty and populated partitions have the same schema.
Incremental refresh examples
AddConvertMsToUtcDateTime for the GET and POST examples.
Use an inclusive start and exclusive end (RangeStart <= timestamp < RangeEnd) so adjacent partitions neither overlap nor omit boundary records. Nested fields such as metadata and properties are returned as JSON text for a stable, loadable schema. Expand them into explicitly typed columns instead if you need to report on individual properties.
These examples partition by createdTime; updates and deletions of older objects are not captured after their partitions stop refreshing.
GetCDF example
This example shows how to configure an incremental refresh when fetching CDF events using theGetCDF function with a URL parameter filter:
Incremental refresh with GetCDF
PostCDF example
This example shows an incremental refresh when fetching data modeling nodes with thePostCDF function:
Incremental refresh with PostCDF
GraphQL example
This example shows how to implement an incremental refresh with a GraphQL query for data model instances:Incremental refresh with GraphQL
ODataCDF example
This example shows incremental refresh with ODataCDF using column-level filtering, which Power BI can push down to the server. Note that when using OData you don’t need to enforce any schema since the OData service always returns a table with the same schema, even if no data is returned.Incremental refresh with ODataCDF (column filtering)
Configure an incremental refresh
When you’ve implemented the filtering usingRangeStart and RangeEnd, follow these steps to configure an incremental refresh:
1
Define parameter values for testing
In Power BI Desktop, define
RangeStart and RangeEnd with values that limit the data loaded to a small period for development and testing.2
Apply filtering logic
Apply the filtering logic using one of the supported functions shown in the examples.
3
Load the data
Load the data by selecting Close & Apply in the Power Query editor.
4
Configure incremental refresh policy
Go to the main Power BI Desktop window, right-click the table you want to configure for incremental refresh in the Fields pane. Select Incremental refresh to open the incremental refresh policy configuration window.
5
Publish to Power BI Service
Publish your model to the Power BI Service when you’ve configured the policy.
Refresh in Power BI Service
When you’ve published your model with an incremental refresh policy, follow these steps to refresh data:1
Perform initial manual refresh
Perform a manual refresh to load all historical data according to your policy. This initial refresh will take longer as it needs to build all partitions and load the historical data.
2
Configure scheduled refresh
Configure a scheduled refresh to update only the incremental data according to your policy. These subsequent refreshes will be much faster as they only process the most recent data.
Learn more:
- Microsoft: Incremental refresh and real-time data for semantic models
- Microsoft: Configure incremental refresh for semantic models
- Microsoft: Troubleshoot incremental refresh