Sub topic 7
DirectQuery trade-offs: source load, latency, and DAX or Power Query limits
This chapter assumes you know what DirectQuery does: it sends queries to the source each time a report needs data. It also assumes you can write basic DAX measures and read a star schema. Here you will see what that design costs and which features it restricts.
Source load
Every visual on a report page produces at least one query. A page with eight visuals can send eight queries when it opens. Each slicer change sends them again. With many users, the source database receives all of that traffic.
Two settings limit the damage:
- Maximum connections per data source caps how many queries run in parallel for one model.
- Query reduction options in Power BI Desktop add an Apply button to slicers and filters. They can also turn off cross-highlighting between visuals.
Plan for the source to carry this load. An operational database that also serves orders or payments can slow down for everyone.
Latency
A query to the source has to travel, run, and return. Report speed depends on the source, not on VertiPaq. Common causes of slow DirectQuery reports are:
- Missing indexes on join and filter columns.
- Views with heavy joins or calculations.
- Many-to-many relationships and wide tables.
- A source far from the Power BI service, such as an on-premises server reached through a gateway.
The measure below looks identical in every mode. The engine that runs it differs.
Total Sales = SUMX ( Sales, Sales[Quantity] * Sales[UnitPrice] )In Import mode, VertiPaq evaluates it in memory. In DirectQuery, Power BI translates it into a SQL query for the source.
DAX and modeling limits
Not every DAX function can be translated to SQL. Depending on the source, some time intelligence functions, parent-child functions, and complex iterators may fail or run slowly. Other limits are:
| Area | DirectQuery behavior |
|---|---|
| Calculated columns | Limited to expressions the source can compute. They cannot use functions that only work across rows of other tables. |
| Calculated tables | Evaluated at refresh time on the model side, so they cannot be DirectQuery tables. |
| Auto date/time | Not available. |
| Row limit | Queries return at most 1 million rows to the visual. |
| Power Query | Only steps that fold into the source query are allowed. |
The Power Query rule matters most. In Import mode you can use any transformation, because the data is loaded and then reshaped. In DirectQuery, each step must translate to a native query. If a step cannot fold, Power BI may reject it or switch to a different behavior. Do transformations in the source, such as in a view, and keep the Power Query steps in the model simple.
Folding also matters for Import models. The incremental refresh filter on RangeStart and RangeEnd loads only the needed range because it folds:
let
Source = Sql.Database("myserver.database.windows.net", "SalesDb"),
FactSales = Source{[Schema = "dbo", Item = "FactSales"]}[Data],
Filtered = Table.SelectRows(FactSales, each [OrderDate] >= RangeStart and [OrderDate] < RangeEnd)
in
FilteredSeeing what the source receives
A report visual generates a DAX query like this one. Run it in DAX Studio or capture it in Performance Analyzer, and then watch the SQL the source receives.
EVALUATE
SUMMARIZECOLUMNS (
'Date'[Year],
"Total Sales", [Total Sales]
)
ORDER BY 'Date'[Year]When the trade-offs are acceptable
DirectQuery fits when data must be current to the second, when the data is too large to import, or when policy forbids copying it. Accept the costs by indexing the source, simplifying the model, and testing with realistic user counts.
Exercise
A DirectQuery report on a production SQL database is slow, and the database team reports high CPU at peak hours. Name two changes on the Power BI side and one on the source side that reduce the problem.
Show answer
On the Power BI side, turn on query reduction options (an Apply button on slicers and filters) and reduce the number of visuals per page. On the source side, add indexes on join and filter columns, or expose a view that pre-joins and pre-aggregates the data. Moving transformations out of Power Query and into the source also helps, because only steps that fold can run in DirectQuery.
Exercise
Why can a Power Query step that works in Import mode fail in DirectQuery?
Show answer
In Import mode, Power BI loads the data and then applies the step in its own engine. In DirectQuery, each step must fold into a native query for the source. A step that cannot fold has no source-side translation, so it is not allowed.