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
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
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.