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
curiouspbix0
Helper IV
Helper IV

Pass input parameters across queries off different DB

Hello Power Query Experts.

 

How could I pass a list of input values (eg - City) into a SQL query A running off a System A from an output of another query B running off a different database like Oracle or Sharepoint ?

 

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @curiouspbix0 , 

I need to check requirement to you, did you want to filter data from SQL by parameter(p1), then use SQL's result as parameter value(p2) to filter data from sharepoint, right? You could use parameter(p1) like below to filter multiple value in SQL

let
    Source = Sql.Database("servername", "newsql", [Query="select *  from t#(lf) where id in (SELECT        Value
                               FROM            dbo.Split_String('"&Parameter&"', ',') AS Split_String_1)"])
in
    Source

Then you could click one of SQL result column "Add a new query" and use this in another parameter(p2) in sharepoint. But I can't filter sharepoint dynamically, the p2 value can't change dynamic, it still based on p1's current value in edit queries windows instead of dynamic value when you change in parameter tool.  I am not sure whether this is my design problem or this is by default. 

By the way, I suggest you could @ super users (@Imkef,@Greg_Deckler and @edhans) for more suggestions.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
dax
Community Support
Community Support

Hi @curiouspbix0 , 

I need to check requirement to you, did you want to filter data from SQL by parameter(p1), then use SQL's result as parameter value(p2) to filter data from sharepoint, right? You could use parameter(p1) like below to filter multiple value in SQL

let
    Source = Sql.Database("servername", "newsql", [Query="select *  from t#(lf) where id in (SELECT        Value
                               FROM            dbo.Split_String('"&Parameter&"', ',') AS Split_String_1)"])
in
    Source

Then you could click one of SQL result column "Add a new query" and use this in another parameter(p2) in sharepoint. But I can't filter sharepoint dynamically, the p2 value can't change dynamic, it still based on p1's current value in edit queries windows instead of dynamic value when you change in parameter tool.  I am not sure whether this is my design problem or this is by default. 

By the way, I suggest you could @ super users (@Imkef,@Greg_Deckler and @edhans) for more suggestions.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Pass lets say City list coming of a result from a SQL query A off oracle database A as a filter into query B off SQL DB.

 

How do I tag @ImkeF,@Greg_Deckler and @edhans  on this post ?

Hi @curiouspbix0 ,

please check this post: https://community.powerbi.com/t5/Desktop/Parameterized-SQL-Query-with-query-folding/td-p/171503 

Basically, it doesn't matter where your filter arguments come from.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.