Sub topic 4
Import mode: data copied into memory
This chapter assumes you can build a model in Power BI Desktop, know what a star schema is, and can write a basic DAX measure. Earlier chapters introduced storage mode as a per-table setting and described the VertiPaq engine. Here we look at what Import mode does from the moment you click Refresh to the moment a visual shows a number.
What Import mode does
In Import mode, Power BI copies data from the source into the semantic model. The copy lives in VertiPaq, the in-memory columnar engine. A report query never touches the source. It reads the copy.
Two consequences follow, and most of this chapter is about them:
- Queries are fast and mostly independent of how fast the source is.
- The data is only as fresh as the last refresh.
Import is the default storage mode when you connect to most sources in Power BI Desktop. It is also the mode with the fewest restrictions on modeling and DAX.
The life of imported data
When a refresh runs, the engine follows the same steps whether you trigger it in Desktop or the service.
- Power Query runs each table's query against the source.
- Rows stream into the engine, which encodes and compresses each column separately.
- Relationships, hierarchies, calculated columns, and calculated tables are built or recalculated.
- The new data replaces the old data in one commit.
Report users keep querying the old copy until step 4 finishes. The result is that a refresh never shows users half-loaded data. The cost is memory: during a full refresh, the model can need roughly twice its normal size, because the old and new copies exist at the same time.
The diagram shows the flow of one refresh and one query.
Where the work happens
Import mode splits work between two places, and knowing which does what helps you debug.
At refresh time the source and Power Query do the work. If your steps fold (Power Query translates them into a single native query such as SQL), the source filters, joins, and aggregates before sending rows. If a step breaks folding, Power Query pulls the rows and transforms them itself, which is slower and uses more of the refresh capacity. Check folding by right-clicking a step and looking at View Native Query. If it is grayed out, that step did not fold.
At query time only VertiPaq works. Two parts of the engine cooperate:
- The storage engine scans compressed columns and returns aggregated data. It is multi-threaded and very fast on simple scans, filters, and sums.
- The formula engine evaluates the rest of your DAX logic. It is single-threaded, so measures that force row-by-row work in the formula engine are the usual cause of slow Import models.
Here is a measure that works in Import mode. The storage engine can compute it directly, because it is a sum over a row expression.
Total Sales = SUMX ( Sales, Sales[Quantity] * Sales[UnitPrice] )The same measure will run in other modes too. In Import mode it never turns into SQL. It runs against the in-memory columns.
What Import mode allows
Because all the data is inside the engine, Import has the widest feature support of the three modes:
- All Power Query transformations, including ones that cannot fold.
- Calculated columns and calculated tables, which are computed at refresh and stored.
- The full DAX function library, including time intelligence over a date table.
- Many-to-many relationships and bidirectional filters, subject to normal modeling cautions.
- Row-level security (RLS) rules written in DAX, evaluated inside the engine.
Calculated columns cost memory and refresh time, since they are stored. Prefer to create columns in Power Query or the source when you can, and keep measures for logic that depends on the user's filter selection.
Size limits and capacity
The whole model must fit in memory, so size limits matter.
| Environment | Typical limit for a model |
|---|---|
| Power BI Pro (shared capacity) | 1 GB compressed per semantic model |
| Premium or Fabric capacity | Depends on the capacity SKU. Enable the large semantic model storage format to go beyond the default limits. |
Check Microsoft's current documentation for exact numbers, because they change by SKU and over time. The limit applies to the compressed model size, not the size of the source data. A 20 GB source table can compress to well under 1 GB if its columns have few distinct values.
Refresh in practice
An Import model is current only up to its last successful refresh. In the Power BI service you set a schedule. On shared capacity, Pro limits you to 8 scheduled refreshes per day, and Premium or Fabric capacity allows up to 48. Refreshes also have a time limit, around 2 hours on shared capacity and 5 hours on Premium or Fabric. Treat these as numbers to confirm for your tenant.
Several practical points come up again and again:
- Gateways. If the source is on-premises or in a private network, the service reaches it through an on-premises data gateway. The gateway needs to run, and the data source credentials must be configured for the model.
- Credentials. Refresh uses the stored credentials, not each report viewer's identity. The viewer never connects to the source.
- Failures. A failed refresh leaves the previous data in place and sends a notification to the owner. Users keep seeing old numbers without any warning on the report, so show a "last refreshed" value somewhere visible.
- Full reloads. Without incremental refresh, every refresh reloads every table in full. That is the main cost of Import on large fact tables, and the next chapter addresses it.
The usual way to cut refresh cost for large tables is to filter on the reserved RangeStart and RangeEnd parameters, so Power BI can split the table into date-based partitions and reload only recent ones. Here is the query pattern. The filter must fold to the source for the savings to be real.
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
FilteredUse >= on one boundary and < on the other, not >= on both. Otherwise rows that fall exactly on a boundary appear in two partitions and get counted twice.
Row-level security and security behavior
RLS in Import mode is defined as DAX filters on tables in the model and is applied by the engine when a user queries. Because the copy contains every row the refresh loaded, RLS is the only thing hiding rows from users. The source's own permissions do not apply at query time. If the refresh account can read all rows, the model holds all rows, so protect both the model roles and who can access the semantic model.
Common errors
- Model exceeds the size limit. Reduce columns and cardinality, filter history out in Power Query, or move to a capacity with a larger limit.
- Refresh runs out of memory. The model needs headroom for the old and new copies. Use incremental refresh so only partitions reload, or reduce model size.
- Refresh times out. Check whether steps fold, add a filter at the source, or partition the table.
- Numbers look stale. Check the refresh history in the service. A paused schedule, expired credentials, or an offline gateway are the usual causes.
- Slow visuals despite Import. Look for expensive calculated logic in the formula engine, many-to-many relationships on large tables, or very high-cardinality columns used in slicers. Chapter 15 covers Performance Analyzer.
When Import fits
Import is the first choice when the data fits within the size limit, the business can accept data as old as the refresh schedule allows, and you want full DAX and modeling freedom. It is weaker when you need near real-time numbers, when the data is too big to hold, or when policy forbids copying data out of the source. Those cases lead to DirectQuery and Direct Lake, which later chapters cover.
Exercise
A report on an Import model shows yesterday's sales figures even though new orders were placed this morning. The source database is up and returns today's orders when queried directly. Name two likely causes inside Power BI, and explain why a viewer's own access to the source does not change what the report shows.
Show answer
Likely causes: the scheduled refresh has not run yet (or is set to a low frequency), or the last refresh failed, for example from expired credentials or an offline gateway, so the previous copy stays in place. Viewers do not change the result because in Import mode report queries read only the in-memory VertiPaq copy built at the last refresh. The source is contacted only during refresh, using the stored credentials.
Exercise
You add the filter [OrderDate] >= RangeStart and [OrderDate] <= RangeEnd to a fact table query. Why can this cause incorrect totals once incremental refresh is enabled, and what is the fix?
Show answer
Both boundaries are inclusive, so a row that falls exactly on a partition boundary is loaded into two adjacent partitions and counted twice. The fix is to use >= on RangeStart and < on RangeEnd.