Forum Discussion

Tracy000's avatar
Tracy000
Helper I
1 year ago
Solved

How to pass a value to SQL DB DirectQuery where condition

Hi team,   I have a PBI file with many tables there, all of these tables come from SQL Server (DirectQuery). I wrote SQL statements in the Advanced options part, like following: select A, B, C, D...
  • SamWiseOwl's avatar
    1 year ago

    Hi Tracy000 

    You can right click on your query and change it into a parameter.

     

    Then connect to SQL put your code under the Advanced section.

     

     

    After your code has connected, on the right hand side under Applied steps click on Source (not the cog).

    This will show your code in the M editor above your table.

     

    Go to where you want to pass in the parameter and split the SQL script using '" & yourparameter & "' that will insert your parameters value into the code 🙂