Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Microsoft Employee
Microsoft Employee

How to make Direct Query use "WITH (NOEXPAND)" in native SQL queries for indexed views.

Is it possible to configure PowerBI so that Direct Queries referencing indexed views pass the "WITH (NOEXPAND)" hint?






Community Support
Community Support

Hi , @claudiop 

As far as I know, if you use Direct query to connect to SQL data sources, you may encounter large limitations if you want to use DAX to create some calculated columns/tables to achieve some requirements, but if you use measures, you will not encounter limitations in the use of DAX functions:

DirectQuery in Power BI - Power BI | Microsoft Learn


So for your needs, I have two ideas to suggest that you can try explore whether there is a chance to achieve:

You can directly try to use measures to use DAX to create the logic you need to implement, according to my research on the With() function in SQL Statement, it seems that the implementation first defines a query, and then the query (virtual table) that applies this definition later is doing other logical operations, right? If this is the case, I recommend that you try "VAR" in DAX to define variables (virtual tables) and use the addcolumns() function to achieve your needs:
ADDCOLUMNS function (DAX) - DAX | Microsoft Learn


You can try to connect to the data source using DQ mode, expand use Native query to connect to the data source, and directly enter the SQL statement you define in SQL to return the expected output in the native query:
Power Query SQL Server connector - Power Query | Microsoft Learn



Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 


Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors