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
Anonymous
Not applicable

Query SQL table with another Query

Hey guys,

 

Not sure if this is possible but just looking for some help.

 

Let's say i have two tables in Power query -  one is data loaded from an Excel file and the other is loaded from an SQL Database.

 

Now let's say the SQL table is indexed on OrderRef and I have an Excel file that contains an ever changing list of OrderRef, how would I use the OrderRef collumn in my loaded Excel sheet to query the OrderRef collumn in the SQL Table? 

 

I've looked into using the List.Contains function and setting it as a filter but not sure if I'm on the right track.

 

Thanks in advance!

 

S

4 REPLIES 4
edhans
Super User
Super User

List.Contains would work, but you might just want to use a MERGE and use an Inner Join between the Excel and SQL table



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hey @edhans  Thanks for the suggestion!

I've tried using the merge option but the query tries to load everything from the database even though I'm selecting the same two collums and my look up table only has 5000 references. The database gets to around 500k and ends the query

 

Is there a way to prevent this?

 

Thanks

 

S

You can try List.Contains using the method described here.

THat will fold, but it uses an IN statement in SQL, which may not be any faster.

 

Something somewhere has to load the entire database to see what should be part of the data returned. It has to evaluate EVERY record, so if you can get a merge to fold (which you cannot with Excel data) then the server would do the merge and return only what you need. If you cannot get it to fold, then you have to let Power Query load the whole thing.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Great, thank you. I'll try this method today and update if it's successful. As suggested on the site I will download the test server and data and try it on there first!

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