Sub topic 7
DirectQuery trade-offs: source load, latency, and DAX or Power Query limits
This chapter assumes you can build a star schema model in Power BI Desktop, write basic DAX measures, and read simple SQL. You should also know that DirectQuery leaves data at the source and sends queries to it at report time. Here you will learn what that design costs and which modeling features it restricts.
Where the costs come from
In Import mode, the VertiPaq engine answers every query from memory. In DirectQuery mode, no data is stored in the model. Each time a visual needs data, the semantic model translates the DAX query into the source's query language, usually SQL, sends it, and waits for the result.
All DirectQuery trade-offs follow from that one change. The source database does the work, so report speed depends on the source. Every interaction produces source queries, so report usage becomes source load. The model must be able to translate its logic into SQL, so some DAX and Power Query features are limited.
Source load
Each visual sends at least one query, and some send several. A page with ten visuals can send ten or more queries on load. A slicer change sends another batch. Multiply that by the number of people using the report at the same time, and the source database sees a steady stream of analytical queries it may not have been sized for.
Several mechanisms add to the load:
- Cross-highlighting and cross-filtering. Selecting a bar in one visual re-queries the other visuals on the page.
- Dashboard tiles. Tiles pinned from DirectQuery reports refresh on a schedule, which sends queries even when nobody is viewing the report.
- Automatic page refresh. A short refresh interval sends the whole page's queries on every tick.
- Concurrency limits. The model opens a limited number of connections to each source (the default is 10 per data source in Desktop). Extra queries wait in a queue, which shows up as latency instead of load.
You can reduce the load without changing the storage mode:
- Put fewer visuals on each page.
- In Desktop, open Options > Current file > Query reduction. Turn off cross-highlighting by default and add an Apply button to slicers and filters so the page does not re-query after every selection.
- Raise the maximum connections per data source if the source and your capacity can handle it.
- Use query result caching or a read replica where your platform supports them, so reporting does not compete with transactional workloads.
Latency
A DirectQuery visual is as slow as its slowest query plus the network path. Anything that lengthens the path shows up in every interaction:
- On-premises gateway. Each query travels through the gateway machine, so its CPU, memory, and network location matter.
- Single sign-on. Passing each user's identity to the source can prevent connection reuse and adds per-user overhead.
- Source design. Unindexed filter columns, wide tables, and views with expensive joins slow every query. Import mode would pay that cost once per refresh. DirectQuery pays it on every click.
- Distance. A source in a different region from the capacity adds round-trip time to every query.
Most fixes belong in the source. Add indexes or columnstore indexes on the fact table, materialize expensive views, and keep dimension tables small and narrow. You can also add relationship settings, described below, and aggregation tables, covered in a later chapter.
How DAX runs in DirectQuery
Your DAX measures are the same text in every mode. What changes is where the work happens. This measure works in all three modes:
Total Sales = SUMX ( Sales, Sales[Quantity] * Sales[UnitPrice] )In Import mode, VertiPaq scans the compressed columns. In DirectQuery mode, the engine translates the measure into SQL. The query that a visual sends looks roughly like this (illustrative, since the exact text varies by source and version):
SELECT
d.[Year],
SUM(s.[Quantity] * s.[UnitPrice]) AS [Total Sales]
FROM [dbo].[Sales] AS s
LEFT OUTER JOIN [dbo].[DimDate] AS d
ON s.[DateKey] = d.[DateKey]
GROUP BY d.[Year];When the engine can push the whole calculation to the source, the source returns a small result. When it cannot, the engine fetches more rows and finishes the calculation itself. Complex measures that mix many filter contexts often produce several SQL queries per visual, or very large intermediate results.
You can see this behavior by running a visual-style query and comparing storage modes in DAX Studio or in the Performance Analyzer query view:
EVALUATE
SUMMARIZECOLUMNS (
'Date'[Year],
"Total Sales", [Total Sales]
)
ORDER BY 'Date'[Year]Relationship settings that matter
By default, the generated SQL uses outer joins between fact and dimension tables, because a fact row might have a key with no match in the dimension. If your source enforces referential integrity, turn on Assume referential integrity on the relationship. The engine then uses inner joins, which most databases optimize better. Do not enable it if orphan keys exist, because those fact rows will silently disappear from the results.
Bi-directional relationships and many-to-many relationships also generate more complex SQL. Use them only when you need them.
DAX limits
The following limits apply to tables in DirectQuery mode:
- Calculated columns are limited to values from the same row. They cannot use aggregate functions, and they can use only scalar functions that can be pushed down to the source.
- Row limit on intermediate results. A query that returns more than 1,000,000 rows from the source to the engine fails. The limit applies to rows the source returns for an intermediate step, not to the rows the visual finally shows. On Premium and Fabric capacities, an administrator can change this limit. A measure that groups by a high-cardinality column and then filters in DAX can hit this limit even when the final chart has only a few points.
- Time intelligence. The automatic date/time hierarchy is not available. Build a proper date dimension table and use it. Time intelligence functions on DirectQuery tables can generate heavy SQL.
- Parent-child and some statistical functions. Some functions are unsupported or perform poorly when the engine cannot translate them.
Power Query limits
Power Query steps in a DirectQuery table must be translatable to the source query. This is called query folding. A foldable step becomes part of the native query. A step that cannot fold has no place to run, because there is no refresh step where Power Query could process rows locally.
For this reason, the Power Query editor in DirectQuery mode restricts transformations. You can usually filter rows, select columns, rename columns, and perform simple joins and groupings, as long as the connector can translate them. Steps that need local processing, such as Table.Buffer, are not available, and Desktop will tell you when a step is not supported in DirectQuery mode.
let
Source = Sql.Database("myserver.database.windows.net", "SalesDb"),
FactSales = Source{[Schema = "dbo", Item = "FactSales"]}[Data],
Recent = Table.SelectRows(FactSales, each [OrderDate] >= #datetime(2025, 1, 1, 0, 0, 0)),
Slim = Table.SelectColumns(Recent, {"OrderDate", "ProductKey", "Quantity", "UnitPrice"})
in
SlimBoth steps fold, so the source receives a single SELECT with a WHERE clause. To check, right-click the last step and look for View Native Query. If the option is unavailable, a step in that chain does not fold.
If you need transformations that do not fold, move them into the source as a view or a prepared table, or use Import mode for that table.
Summary of the trade-offs
| Concern | Import | DirectQuery |
|---|---|---|
| Data freshness | As of last refresh | Current at each query (subject to caching) |
| Query speed | Fast, in memory | Depends on the source and network |
| Source load | During refresh only | On every interaction by every user |
| Model size limits | Memory of the capacity | Source capacity and the 1,000,000-row limit |
| DAX and Power Query | Full feature set | Restricted to what translates to the source |
DirectQuery is a good fit when the data must be current to the minute, when the data is too large to import, or when data residency rules keep data at the source. If none of those apply, Import is usually faster and simpler. Later chapters cover composite models and aggregations, which keep the benefits of DirectQuery for large tables and use memory for the parts that need speed.
Exercise
A report has a DirectQuery fact table with 500 million rows. After you publish it, users complain that every slicer click takes 20 seconds and the source DBA reports a spike in concurrent queries. Name three changes that reduce the problem without changing the storage mode of the fact table.
Show answer
Any three of these: add an Apply button to slicers and turn off cross-highlighting through Query reduction settings so fewer queries are sent. Reduce the number of visuals per page. Add indexes or columnstore indexes on the fact table's filter and join columns, or materialize an expensive view. Turn on Assume referential integrity on fact-to-dimension relationships if the source guarantees it, so the source can use inner joins. Raise the maximum connections per data source if the source can handle more concurrent queries. Add aggregation tables for common summary queries.
Exercise
You switch a table from Import to DirectQuery. A Power Query step that used Table.Buffer now causes an error, and a calculated column that sums values from a related table no longer works. Explain why each one fails.
Show answer
Table.Buffer needs local processing of rows, and a DirectQuery table has no local copy of the data, so the step cannot fold into the source query and is not supported. The calculated column uses a function that reads from another table (an aggregate across rows), and DirectQuery calculated columns can reference only values from the same row and only functions that can be pushed down to the source.