Using DirectQuery in Power BI Datasets

What if your Power BI dashboard could reflect changes the instant they happen?

No waiting for scheduled refreshes, no exporting massive files, just live insights pulled straight from your database.

That’s what DirectQuery can do for you.

Typically, Power BI reports use Import mode, where data is copied into the .pbix file.

This makes reports fast, but only as fresh as the last refresh.

DirectQuery flips that model. Instead of importing data, Power BI queries your source in real time.

Whenever you interact with a visual, it fetches the latest data directly from the database.

This approach is perfect for:

  • Real-time dashboards that track live sales, inventory, or IoT streams
  • Large datasets that are too big to load into memory
  • Secured or governed data that can’t leave the source

While DirectQuery unlocks real-time analytics, it also comes with tradeoffs like limited DAX capabilities and dependency on database performance.

Used correctly, it delivers speed, scalability, and trust in your analytics.

Section title image that reads

Benefits of DirectQuery

  • Real-time or near real-time insights – Always work with the latest data
  • Smaller Power BI files – No large imports stored in the .pbix
  • Centralized security and governance – Data stays in its source system
  • Ideal for very large datasets – Skip long refreshes and memory issues
  • Combines well with composite models for flexible reporting scenarios

Using DirectQuery With Composite Models

Understanding Composite Models

Composite models allow you to combine multiple datasets and data sources in a single Power BI model.

  • You can connect live to a corporate semantic model (Power BI dataset)
  • Add local or imported data (like Excel files or small lookup tables)
  • Blend live and imported data for flexible reporting

The composite model made up of several connected datasets

Step‑by‑Step: Using DirectQuery in Power BI

Step 1: Open Power BI Desktop

Go to Home > Get Data > SQL Server

Power BI screenshots with highlights on where to enter server address and select DirecrQuery

Step 2: Select Your Dataset

Pick the dataset to connect live. Power BI will establish a DirectQuery connection.

Step 3: Add Additional Data Sources (Optional)

If needed, you can also connect to additional data sources such as Excel files or external databases!

These can be combined with your original dataset using composite models, allowing for greater flexibility and richer analysis.

To ensure optimal performance, always choose connectors that support DirectQuery and enable query folding wherever possible.

Trainer Insight: One of the biggest mistakes we see is discovering your DirectQuery lags badly for end users.

Always test your report’s responsiveness on real user machines, not just your development environment.

We cover this on our Power BI courses – as speed, permissions, and query load can vary widely!

Section title image that reads

Best Practices

  • Monitor performance using Performance Analyzer in Power BI
  • Collaborate with database administrators to tune and index source databases
  • Label pages or visuals that rely on live data for clarity
  • Ensure On-premises Data Gateway is stable for live connections
  • Regularly check connector support for DirectQuery features and updates

Section title image that reads

Troubleshooting Common Issues

If your visuals are loading slowly, try reducing the number of visuals per page and optimizing the underlying source queries.

When query folding unexpectedly stops working, simplifying your Power Query transformations can often help.

For credential or permission errors, double-check your dataset permissions and gateway configuration.

If you encounter row limit errors, consider reducing data granularity or switching to import mode for high-volume visuals to improve stability and responsiveness.

Trainer Insight: If a DirectQuery visual suddenly stops working or throws an error, don’t waste hours debugging.

Rebuilding the visual from scratch often resolves unexpected glitches caused by metadata conflicts or stale query dependencies.

Conclusion

DirectQuery in Power BI empowers you to deliver real-time insights without ballooning your file size.

When combined with composite models and aggregations, it allows you to achieve the best of both worlds – live dashboards with reliable performance.

About Ben Richardson

Ben is a director of Acuity Training which he has been running for over 10 years.


He is a Natural Sciences graduate from the University of Cambridge and a qualified accountant with the ICAEW.


He previously worked as a venture capitalist and banker and so had extensive experience with Excel from building financial models before moving to learn SQL, Microsoft Power BI and other technologies more recently.