Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

SQL Select Query in Advanced Editor for a DirectQuery

Hello   I am trying to set up a DirectQuery connection to a DB2 database in Power Query, I am using the IBM DB2 connector   I have a SQL query that performs multiple joins in the database to save...
  • BA_Pete's avatar
    2 years ago

    Hi Anonymous ,

     

    There's a couple of issues here:

     

    1) As Anonymous has noted, SQL statements can't ordinarily be used for Direct Query models as they are not 'foldable'. Due to how DQ works (i.e. it creates SQL queries for each visual in the report) it must be based on Power Query data that can be entirely converted (internally) to an SQL query to begin with.

    More information on this here: https://learn.microsoft.com/en-us/power-bi/guidance/power-query-folding 

    You *may* be able to resolve this by using the Value.NativeQuery function in PQ and using the [EnableFolding=true] optional parameter, but I'm honestly not sure if this will work as expected, especially on DB2 which can be rather more finicky that MS SQL Server, for example.

    More information on this here: https://learn.microsoft.com/en-us/powerquery-m/value-nativequery 

     

    2) Your REPAYMENT1 step isn't referring to a previous step. I would suggest that the DBNAME part here should probably read DB2S, referring to the previous step. This isn't going to fix your folding issue though.

     

    Pete