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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Shiroe
Helper I
Helper I

Use power bi parameters in a query through native query

Dear partners,

Kindly request your help, I am trying to pass parameters to a query that uses native query, but it does not recognize the parameter of power bi

I have tried appending it to the sql query

1. '@parameter'
2.  '"& Parameter &"'

defining the parameter inside the nativequery, nothing has worked for me I need to pass that parameter created in power bi to the query.

 

I'd appreciate your help. I attach an example

 
example1 :
 
let
  Source = Oracle.Databases("localhost"),
  Query =Value.NativeQuery(
      Source,
    "SELECT column1,column2 FROM example1 where column1 between @parameter1 and @parameter2",
[parameter1 = #"paramter1", parameter2 = #"parameter2"])
in
Query
 
 
example 2
 
let
  Source = Oracle.Databases("localhost"),
  Query =Value.NativeQuery(
      Source,
    "SELECT column1,column2 FROM example1 where column1 between '"& Parameter1 &"' and '"& Parameter2 &"'")
in
Query
1 ACCEPTED SOLUTION

Hi, @Shiroe 

You can refer to the solution proposed by @kailas684  in this thread.


Step#1: Create Parameter pID [text parameter and keep default value]

Step#2: On Dataset that is pulled on Query Editor, right click and go to Advanced Editor. Edit below code as per your database and table name.

let
    pID=ID,
    Source =
    Oracle.Database("your database name",
    [HierarchicalNavigation=true,
    Query="SELECT * FROM MYtableName#(lf) where DA_LOAN_ID='"&pID&"'"])   
in
    Source


Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Shiroe , check if this can help.

https://www.fourmoo.com/2020/10/08/power-query-m-passing-parameters-dynamically-to-a-sql-server-quer...

 

But this may be limited to SQL server

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

unfortunately friend, I am using an oracle database, I need to use dynamic parameters in native query keeping in mind this database. If you have any additional information that can help me I would appreciate it to be able to pass parameters from power bi dynamics to native query

Hi, @Shiroe 

You can refer to the solution proposed by @kailas684  in this thread.


Step#1: Create Parameter pID [text parameter and keep default value]

Step#2: On Dataset that is pulled on Query Editor, right click and go to Advanced Editor. Edit below code as per your database and table name.

let
    pID=ID,
    Source =
    Oracle.Database("your database name",
    [HierarchicalNavigation=true,
    Query="SELECT * FROM MYtableName#(lf) where DA_LOAN_ID='"&pID&"'"])   
in
    Source


Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.