Sub topic 3
Creating the RangeStart and RangeEnd parameters
This chapter assumes you can connect Power BI Desktop to a relational source and load a table in Import mode. It also assumes you know the Power Query Editor and its Applied Steps pane. The previous chapters explained why full refresh scales poorly and why query folding matters. Here you create the two parameters that incremental refresh depends on.
What the parameters do
Incremental refresh needs a way to ask the source for one slice of dates at a time. Power BI uses two reserved parameters for this: RangeStart and RangeEnd. You define them in Power Query, and you use them in a filter on the large table (the next chapter covers that filter).
The parameters play two roles.
- In Power BI Desktop, their values decide how much data you load while you build the report. A small range, such as one month, keeps the model small and the editor fast.
- In the Power BI service, your values are ignored. For each partition, the service substitutes its own start and end dates and runs the query once per partition.
So the values you type are only a development slice. They do not decide what ends up in the published model.
Create the parameters
Do this in the Power Query Editor. In Power BI Desktop, choose Home > Transform data.
- In the editor, choose Home > Manage Parameters > New Parameter.
- Set Name to
RangeStart. - Set Type to Date/Time.
- Leave Suggested Values as Any value.
- Enter a Current Value, for example
1/1/2020 12:00:00 AM. - Select OK, then repeat for
RangeEndwith a later current value, for example2/1/2020 12:00:00 AM.
The editor stores each parameter as a query with a meta record. In the Advanced Editor, the two parameters look like this:
RangeStart = #datetime(2020, 1, 1, 0, 0, 0) meta [IsParameterQuery = true, Type = "DateTime", IsParameterQueryRequired = true]
RangeEnd = #datetime(2020, 2, 1, 0, 0, 0) meta [IsParameterQuery = true, Type = "DateTime", IsParameterQueryRequired = true]Each parameter is a separate query, so each has its own Advanced Editor view.
Rules that cannot be bent
The service looks for these parameters by name and type. If either is wrong, the Incremental refresh option stays unavailable or the policy fails later.
| Requirement | Correct | Common mistake |
|---|---|---|
| Name | `RangeStart`, `RangeEnd` | `rangestart`, `Range_Start`, `StartDate` |
| Type | Date/Time | Date, Text, or Date/Time/Timezone |
| Required | Yes (a current value is set) | Leaving the current value empty |
Names are case-sensitive. A parameter called Rangestart is an ordinary parameter, and Power BI ignores it for incremental refresh.
The type must be Date/Time, even if your source column is a plain date. If the source column is a date or an integer key, you convert inside the filter step instead of changing the parameter type. The filter chapter shows the integer-key case.
Choosing development values
Pick a range that is small but still contains rows. A range with no matching rows gives you an empty table, which makes it hard to check column types and later steps.
Keep these points in mind:
RangeStartmust be earlier thanRangeEnd.- A range of a few days to a month is usually enough for development.
- Changing the current values later is safe. It only changes how much data Desktop loads.
Check your work
Open the Queries pane and confirm that both parameters appear with the parameter icon. Select each one and check that the type shows as Date/Time in the parameter settings. If you rename a parameter later, any filter step that referenced the old name breaks, so fix the names before you build the filter.
Exercise
A colleague created parameters named RangeStart and RangeEnd with type Date, because the source column OrderDate is a date. The Incremental refresh option does not work. What is wrong, and how should the setup be corrected?
Show answer
The parameters must have the Date/Time type, not Date. Change both parameters to Date/Time and keep the exact names. Because OrderDate is a date, handle the difference in the filter step, not in the parameter type.
Exercise
You set RangeStart to 1 January 2020 and RangeEnd to 1 February 2020 in Desktop. After publishing with a refresh policy, does the service load only January 2020?
Show answer
No. In the service, each partition replaces the parameter values with its own dates. Your values only limit the data loaded in Power BI Desktop during development.