Sub topic 4
Import mode: data copied into memory
This chapter assumes you can build a basic Power BI Desktop model with a star schema and write simple DAX measures. It also assumes you know what a relational database and SQL are. Fabric knowledge is not needed here.
What Import mode does
Import is the storage mode in which Power BI copies data from the source into the semantic model. The copy lives in the VertiPaq engine, which is an in-memory columnar store. After the copy finishes, report queries no longer touch the source. They read the compressed columns held in memory.
Import is the default when you connect to most sources in Power BI Desktop. You can confirm a table's mode in Model view. Select the table and open the Advanced section of the Properties pane, where Storage mode shows Import.
Why queries are fast
Three properties explain the speed.
- Data is stored by column, so a query that needs two columns reads only those two.
- Each column is compressed, which lets large tables fit in memory.
- The engine answers queries itself and does not wait on a network call to the source.
A measure such as the following runs entirely inside VertiPaq.
Total Sales = SUMX ( Sales, Sales[Quantity] * Sales[UnitPrice] )Import also gives you the most freedom. The full DAX language and all Power Query transformations are available, because the data is already in the model.
The cost: a snapshot
The copy is a snapshot. Data in the model is only as fresh as the last refresh. A refresh re-runs the queries against the source and replaces the data in memory. If the source changes at 10:00 and the last refresh ran at 08:00, reports show the 08:00 values.
Import also has these costs:
- The model must fit within the memory and size limits of your license or capacity.
- Each refresh puts load on the source and takes time, which grows with data volume.
- The data is stored twice, once at the source and once in the model.
Keeping the snapshot current
You schedule refreshes in the Power BI service. A full refresh reloads every table, which is simple but slow for large facts. For big tables, incremental refresh loads only recent partitions. It relies on two reserved datetime parameters, RangeStart and RangeEnd, and a filter like this one.
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. This avoids loading a row into two partitions. The next chapter covers incremental refresh in detail.
Common errors
- Stale reports. Users see old numbers because no refresh is scheduled, or a scheduled refresh failed. Check the refresh history.
- Refresh timeouts. A full reload of a large table exceeds the time limit. Use incremental refresh or reduce the columns you import.
- Model too large. Importing every column "just in case" inflates memory use. Remove columns you do not use, and avoid high-cardinality text columns, such as GUIDs, where you can.
- Query folding is lost. If a Power Query step cannot be translated to SQL, the engine pulls the data and filters it locally. A filter on
RangeStartandRangeEndthat does not fold makes every partition read the whole table.
When Import fits
Choose Import when the data fits in memory, when hourly or daily freshness is acceptable, and when you need full DAX and modeling features. It is usually the best default for speed.
Exercise
A report built on an Import model shows yesterday's totals, although the source table was updated an hour ago. What is the most likely cause, and what are two ways to reduce the delay?
Show answer
The model holds a snapshot from the last refresh, and the refresh has not run since the source changed. You can schedule refreshes more often, or use incremental refresh so each refresh is faster and can run more often. If the data must be current at query time, a different storage mode such as DirectQuery or Direct Lake would be needed.