Choose the Import mode for fast, interactive reports on static data, or use Direct Query for real-time analytics on live data sources without storage costs. This guide explains the difference, when to use each mode, and how to switch between them in Power BI Desktop.
What You'll Need
- A Power BI Desktop application installed on your computer.
- Access to a data source supported by Power BI, such as SQL Server, Azure SQL, or an online service like SharePoint Online.
- Basic knowledge of Power Query to understand how data is being transformed and loaded.
Step-by-Step
Follow these steps to understand the difference between the two modes and how to configure your data model.
- Open Power BI Desktop. Launch the application and load the report you want to analyze.
- Open the Data Source Settings. Click on the Modeling tab in the ribbon at the top of the screen. In the ribbon, select Data Source Settings.
- Identify the Data Source. In the dialog that appears, you will see a list of all the data sources currently connected to your model. Select the specific data source you wish to change (e.g., an SQL Server database) and click Settings.
- Change the Load Option. In the data source settings window, look for the Load Option dropdown menu. It will likely default to Import.
- Select Direct Query. Change the dropdown to Direct Query. This tells Power BI to connect directly to the data source when the report is opened, rather than copying the data into the local file.
- Apply the Change. Click OK to save the setting for this data source. Power BI will prompt you to refresh the data model to apply the new connection type.
- Refresh the Model. Confirm the refresh. Depending on the size of the data source, this may take a moment. Once complete, the model is now using Direct Query.
- Verify the Connection. Go to the Home tab and click Refresh. A message will appear indicating that the data was retrieved from the live source rather than the local cache.
Understanding the Modes
It is important to understand what happens under the hood when you select one mode over the other.
Import Mode pulls data from your source into the Power BI Desktop file. This makes the report very fast because the data is already on your computer. However, the data becomes stale as soon as the refresh job finishes. To get the latest numbers, you must manually press refresh or set up a scheduled refresh in the Power BI service.
Direct Query Mode does not bring data into the file. Instead, it creates a metadata link back to the original database. When you interact with a report, Power BI sends the query to the live database and returns the answer. This keeps your data model small and ensures you are always looking at the most up-to-date numbers, but it can be slower to load visuals because of the network delay.
Common Mistakes
Users often switch modes without considering the impact on their report's performance and functionality.
- Using Direct Query on small datasets. If you have a small table with only a few hundred rows, importing the data is much faster. Direct Query adds network latency that you don't need for such small volumes.
- Ignoring aggregation limits. Direct Query can only handle a limited number of rows in a single query sent to the database. If you try to pull millions of rows into a visual, the database may time out or return an error. You must use DAX measures and Power Query aggregations to keep the query size down.
- Overlooking row-level security. Row-level security (RLS) works differently in Direct Query. In Import mode, the security is enforced on the local file. In Direct Query, the security is enforced on the live data source. If you set RLS in Power BI Desktop but do not configure it correctly in the database or the Power BI Service, users will see data they shouldn't.
- Assuming all visuals work the same. Some visuals, like the R visual or the Map visual, rely on having the data loaded locally to calculate geographic coordinates. They often do not work well with Direct Query unless the data is pre-aggregated in Power Query.
Tips for Success
To get the best performance from either mode, keep these best practices in mind.
- Use a star schema. Whether you use Import or Direct Query, a star schema (a central fact table connected to dimension tables) is essential. This structure reduces the amount of data the database has to scan.
- Limit the number of columns. In Direct Query, every column you select in a visual adds to the query sent to the database. Only include the columns you need in your data model to prevent bloated queries.
- Pre-aggregate data in Power Query. When using Direct Query, do as much work as possible in Power Query. Calculate totals, averages, and filters before the data even reaches the DAX engine. This reduces the load on the live database.
- Check data source compatibility. Not all data sources support Direct Query. Before switching, ensure your specific version of SQL Server, Oracle, or cloud data warehouse supports the feature.
- Monitor refresh times. In the Power BI Service, keep an eye on your scheduled refresh times. Direct Query reports do not have a fixed refresh time; they load data instantly when you open the report. However, if you click refresh, the live database must process the request.
Troubleshooting
If you encounter issues when switching between modes or working with Direct Query, try these steps in order.
Issue: Report is slow to load.
Solution: This is expected behavior in Direct Query. The data is being fetched over the network. Check your network connection. If the report is still unacceptably slow, consider using Import mode or adding indexes to your database to speed up the queries.
Issue: Error message about exceeding row limits.
Solution: You are likely trying to show too many rows in a table or matrix visual. Switch to a visual that summarizes the data, such as a chart or a KPI card. Alternatively, add a filter to reduce the dataset size.
Issue: RLS is not working.
Solution: Verify that the security policies are defined correctly in the data source settings in Power BI Desktop. In the Power BI Service, ensure that the same RLS is enabled on the dataset and that users have the correct licenses and permissions assigned to them in the workspace.
Issue: Visual shows #Table or #Error.
Solution: This often happens when a calculated column or measure is referencing a table that was removed or renamed. Open the Model view and ensure all relationships are intact. Check the DAX code in the Measure Studio to fix any broken syntax.
Issue: Data looks different after switching to Direct Query.
Solution: If you used Power Query to clean or change data types in Import mode, those changes are not saved in Direct Query because the data is not in the file. You must recreate those transformations in the Power Query editor for the Direct Query connection.
Frequently Asked Questions
Can I use both Import and Direct Query in the same report?
Yes, you can. Power BI allows you to connect to multiple data sources in a single model. You can import one dataset for fast analysis and use Direct Query for another dataset that requires real-time updates.
Does Direct Query cost more in the Power BI Service?
Generally, Direct Query has the same licensing cost as Import. However, you may incur additional costs from your database provider if you are querying a cloud data warehouse, as you are using their compute resources to answer the queries.
Which mode is better for mobile reports?
Import mode is usually better for mobile because the data is cached locally on the device. Direct Query requires a constant internet connection to fetch data, which can slow down the app and drain battery life.
How do I switch back to Import mode?
Repeat the steps in the guide above, but in the Data Source Settings window, change the Load Option dropdown from Direct Query back to Import. You will be asked to confirm that you want to overwrite the local data with the new import.
Why does my Direct Query report fail to refresh in the service?
Refresh failures are usually due to authentication issues. Ensure that the connection details, such as username and password, are saved in the gateway settings or that the service account has the necessary permissions to read from the live database.
Is Direct Query suitable for large datasets?
Direct Query can handle large datasets, but it requires the database to be optimized for querying. If the database is not indexed properly, the report will be slow. For extremely large datasets, Import with data compression is often the preferred choice.