Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

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

  • Hi , Anonymous 

    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