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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
APM
Helper I
Helper I

Reducing query size - querying only data in one table that also appears on all other tables

Hello.

 

I have a 'Product' table, it has a 'Product Code' column and multiple attribute columns. It is an enormous data-set, as it has all the product a company as produced in its history.

 

In addition, I have an 'Inventory' table and a 'Sales' table. These also have a 'Product Code' column.

 

In order to reduce my query size, I want to query only the 'Product Codes' in the 'Product' table that appear in both the 'Inventory' and 'Sales' tables. 

 

How do I do this?

 

I've started with something like this, but it's not working, I may be way off:

 

= Table.SelectRows(#"Product", each List.Contains(Table.Column(#"Inventory", "Product Code"), [Product Code]) and List.Contains(Table.Column(#"Sales", "Product Code"), [Product Code]))

 

Alternatively, maybe I can do a sort of lookup column where if Product Code appears in 'Inventory' and 'Sales', mark an "X", and then query only rows that contain an "X"? But I haven't figured out the code for that route.

 

Thank you!

 

2 REPLIES 2
APM
Helper I
Helper I

Thanks, @HotChilli

I'm very new to writing this kind of code. Do you have an example of how I would need to type that in?

HotChilli
Super User
Super User

Maybe use List.Intersect to create a list of product codes in Inventory and Sales tables.

Then use Table.SelectRows on the Product table with List.Contains passing the list you created and the Product code.

--

I advise reducing your tables to a few rows to use as a test when writing the code

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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