About incremental refresh
Incremental refresh in Power BI partitions your data based on date ranges and refreshes only the most recent data. With this approach, only recent data is refreshed, not the entire data set. Shorter connections to data sources reduce the risk of timeouts, and you can work with data sets that would be impractical to refresh entirely.Before you start
- Make sure the endpoint you want to fetch data from supports timestamp-based filtering.
- The schema must be consistent. Your queries must return a consistent schema even when filtering results in no data.
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
Since CDF endpoints expect timezone-aware timestamps in specific formats, you must convert theRangeStart and RangeEnd values to the appropriate format for each request type:
- 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.
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
Incremental refresh examples
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 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