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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Terrassa
Helper I
Helper I

Filter one query by a column of another query

Hello,

 

I have two queries in Power Query. One query imports all the material master table from the ERP, which includes materials of all the plants of the company (almost 3 million rows and increasing very fast). This table doesn't have any field to filter only the materials of the plant I'm interested in.

 

The other query imports a table of specific parameters of materials per plant, so it has include the field for the materials (to be used as a link with the material master table) and a field for the plant. This query only has 80K rows.

 

I'd like to filter the query of the material master to import only the materials that exist in the query of materials per plant, so only 80K rows are imported in both queries. I don't want to merge both tables in one single query but to keep both tables separated.

 

Is this possible in Power Query?

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @Terrassa ,
yes, that's possible:
You start from having both tables imported.
Then add a step to the first materials master table that filters that table to only include that rows with matching entries in the 2nd table. 
This can be done by a merge with inner join for example.

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

View solution in original post

3 REPLIES 3
ImkeF
Community Champion
Community Champion

Hi @Terrassa5 ,
that would be called "query folding".
If both tables come from the same source/database, folding should happen.
But if the small tables comes from a non-sql-source, there is a limitation unfortunately.
You would have to create a filter statement like described here:
Solved: Parameterized SQL Query with query folding - Microsoft Fabric Community
for more information about it, please check out this article as well:
SQL-query folding bug still alive and sucking in PowerBI and PowerQuery in Excel – (thebiccountant.c...

 

 

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

ImkeF
Community Champion
Community Champion

Hi @Terrassa ,
yes, that's possible:
You start from having both tables imported.
Then add a step to the first materials master table that filters that table to only include that rows with matching entries in the 2nd table. 
This can be done by a merge with inner join for example.

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

I would like to avoid importing the whole material master table because it's increasing very quick and soon it will be more than 10 million records and the updates will be very slow (incremental update is not possible).

 

Is it possible to do the filtering before importing so only the records of the materials that exist in the materials per plant table are imported?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.