Sub topic 11
Hybrid tables: adding a DirectQuery partition for the latest data
This chapter assumes you have built an incremental refresh policy with RangeStart and RangeEnd, and that your date filter folds to the source. It also assumes you know the difference between Import and DirectQuery storage modes. The chapter covers what a hybrid table is, what it costs, how to turn it on, and what to check when it misbehaves.
The gap that remains after incremental refresh
Incremental refresh makes each refresh cheaper, but the data is still only as fresh as the last refresh. If you refresh eight times a day, a report can be hours behind the source. Refreshing more often shrinks the gap, but each refresh still runs queries for the whole incremental window and then processes the partitions.
A hybrid table closes the gap differently. The table keeps its Import partitions for the archive and incremental periods. It also gets one DirectQuery partition that covers the most recent period. When a report asks for recent rows, Power BI queries the source live for that slice and reads everything older from the in-memory cache.
What a hybrid table is
A hybrid table is a single table with two storage behaviors:
- Import partitions hold older data. They are fast and compressed in memory, and they are refreshed by the policy.
- One DirectQuery partition holds the newest data. It is never refreshed, because it has no stored copy. Each query that touches its date range goes to the source.
You still see one table in the model and write the same DAX against it. The split is by date, so a visual that filters to last year never touches the source. A visual that covers today does.
Power BI Desktop does not create the DirectQuery partition. Partitions are created in the service after you publish, the same way the Import partitions are. In Desktop the table remains a normal Import table filtered by RangeStart and RangeEnd.
Requirements and limits
Hybrid tables are more restricted than plain incremental refresh. Check these before you design around them.
- The dataset must be in a workspace on Premium capacity, Premium Per User, Embedded, or Fabric capacity. Incremental refresh alone works on Pro, but the real-time option does not.
- The source must support DirectQuery. Most relational sources do, such as SQL Server, Azure SQL Database, and Synapse. Files and many web connectors do not.
- The table query must fold completely. DirectQuery cannot run a step that Power Query would have to evaluate itself. If a step does not fold, the real-time option fails or refuses to enable.
- The model becomes a composite model, because one table now has both Import and DirectQuery partitions. That affects relationships, as the next section explains.
- Row-level security and credentials apply to the DirectQuery partition too. The identity used to query the source for live data is the one configured on the dataset's data source, so check what that account can see.
Turning it on
You enable the option in the same dialog where you set the archive and incremental periods. Right-click the table in Power BI Desktop and choose Incremental refresh. Set the policy as before, for example to keep 5 years and refresh the last 10 days. Then select Get the latest data in real time with DirectQuery (Premium only).
Desktop shows a warning if the option is unavailable. Common causes are a source that cannot do DirectQuery, or a query that does not fold. Fix the query first and reopen the dialog.
In the model metadata, the table's refresh policy gains a mode of hybrid. This is the same excerpt from the policy chapter with that one setting added:
{
"refreshPolicy": {
"policyType": "basic",
"mode": "hybrid",
"rollingWindowGranularity": "year",
"rollingWindowPeriods": 5,
"incrementalGranularity": "day",
"incrementalPeriods": 10
}
}The value import is the default for a normal incremental refresh policy. The value hybrid tells the service to add the DirectQuery partition when it applies the policy.
Where the DirectQuery partition starts
The incremental window ends at the current period, or at the last complete period if you also chose to refresh only complete periods. The DirectQuery partition covers everything after that boundary, up to the present and beyond.
Consider a policy that refreshes the last 10 days and keeps 5 years, with a daily granularity and a refresh on 27 November.
- Import partitions cover the archive years and the days inside the 10-day window.
- The DirectQuery partition covers the dates after the Import window ends, which includes the current day.
If you combine hybrid mode with Only refresh complete periods, the Import window stops at the last finished period. The partial current period is then served by the DirectQuery partition rather than appearing half loaded in an Import partition. The two options are designed to work together. Review both checkboxes in the dialog, because Desktop may preselect or constrain them when you pick real time.
This also means an Import partition can never contain a partial period when the pair is set. A row that arrives late for yesterday is picked up at the next refresh. A row for today is visible immediately.
Storage modes and relationships
Once a table has a DirectQuery partition, Power BI treats the model as a composite model. A relationship between a table that uses DirectQuery and a table that uses Import is a limited relationship. Limited relationships can change how filters propagate and can affect results in some DAX patterns.
The usual fix is to set the related dimension tables, such as Date, Product, and Customer, to Dual storage mode. A Dual table can serve queries from its cache or push them to the source, depending on what the query needs. That lets the relationship between the fact table and each dimension behave as a regular one in both Import and DirectQuery cases.
| Table | Typical storage mode | Reason |
|---|---|---|
| Fact table with hybrid policy | Import and DirectQuery partitions | Cache for history, live data for the newest period |
| Dimension tables related to it | Dual | Avoids limited relationships when the fact table queries the source |
| Small standalone tables, such as a measure table | Import | Not related to the hybrid table, no reason to change |
Dimension tables in Dual mode must also be queryable at the source. If a dimension comes from a file or a connector without DirectQuery support, you cannot use Dual and may need to restructure.
Checking that it works
After the first refresh in the service, confirm the layout and the live behavior separately.
- Open the workspace in Premium and connect with SQL Server Management Studio or another XMLA client. Expand the table's partitions and look for one partition whose source mode is DirectQuery.
- Change a row at the source, for example insert a test order dated today.
- Without refreshing, run a query that reads the newest date.
This DAX query returns the latest order date the model can see. Run it from DAX Query View, from SSMS, or any client connected to the dataset.
EVALUATE
ROW (
"Latest order date", MAX ( FactSales[OrderDate] ),
"Rows today", CALCULATE ( COUNTROWS ( FactSales ), FactSales[OrderDate] = TODAY () )
)If the test row shows up with no refresh, the DirectQuery partition works. If it does not, check the points in the troubleshooting list below.
Common problems
- The real-time checkbox is disabled or missing. The workspace is not on Premium or Fabric capacity, or the source connector does not support DirectQuery.
- Publishing succeeds but the table has no DirectQuery partition. The policy is applied on the first refresh in the service, not at publish. Run a refresh, then inspect the partitions again.
- Reports are slow for recent dates but fast for old ones. That is expected, because recent dates are read live. Index the date column at the source, or narrow the real-time window with a smaller incremental period and a shorter granularity.
- Totals differ between recent and old periods. Check for limited relationships. Set the related dimension tables to Dual and test again.
- Refresh fails after you add a step to the table query. The new step probably broke folding. Use View Native Query in Power Query on the last step. If it is greyed out, the step does not fold, and DirectQuery cannot use it.
- Users see different data from each other. The DirectQuery partition applies row-level security and the data source credentials at query time. Review the dataset's data source settings and any security rules.
When to use a hybrid table
| Situation | Choice |
|---|---|
| Hours of delay are fine and the source is busy | Plain incremental refresh |
| Users need data from the last few minutes | Hybrid table, if the source and capacity support it |
| The source does not support DirectQuery | Plain incremental refresh with more frequent refreshes |
| Many concurrent users and a fragile source | Plain incremental refresh, because live queries multiply the source load |
| Model has dimensions that cannot be Dual | Rework the model, or avoid hybrid mode |
Hybrid tables suit a narrow case: a large fact table, a capable source, a Premium workspace, and a real need for current data. Outside that case, incremental refresh with a sensible schedule is simpler to run and cheaper for the source.
Exercise
A team has a 5-year, 10-day incremental policy on a fact table. They enable the real-time DirectQuery option, publish to a Premium workspace, and open the report. Recent sales look correct, but a card that compares recent and older totals gives odd results. The Date and Product tables are Import tables. What is the likely cause, and what is the fix?
Show answer
Adding the DirectQuery partition made the model a composite model. The relationships between the Import dimension tables and the hybrid fact table are limited relationships, which can change filter behavior. Set the Date and Product tables to Dual storage mode so the relationships behave as regular ones, and confirm the dimensions can be queried at the source. Then retest the card.
Exercise
You enable the real-time option and publish. The report shows the table, but a check of the partitions through the XMLA endpoint shows only Import partitions. What should you check first?
Show answer
Check whether the first refresh has run in the service. The policy is applied to the dataset at the first refresh, not at publish, so the DirectQuery partition does not exist until then. Run a refresh, reopen the partition list, and confirm that the policy mode is hybrid.