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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors