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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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

4 REPLIES 4
OndrejVyhnal
New Member

Thanks a lot!

So looks like the only way to make this work on Oracle is to set every Power BI parameter as text only. 

I was able to run the query witohur error now, which is great. But a bit woried what other problems it will bring later when integers and dates are set as text and so on...let see I continue with this advanture. 🙂

Have a nice day!

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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