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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
claudiop
Employee
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?

How?

 

Thanks,

Claudio

 

1 REPLY 1
v-yueyunzh-msft
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

 

vyueyunzhmsft_0-1679279810471.png

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

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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