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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
SHDJason
Advocate II
Advocate II

How to model this in Power Query

Hi, I'm new to data modeling with Power Query so please forgive if this is rudimentary stuff. But I need some guidance.  

 

I have 2 tables.

 

Table 1 has products and sales.

 

Table 2 has products and returns.

 

Table 1 has products  = A, B, C

Table 2 has products = B, C, D

 

For products B and C, I want to show sales and returns.

For the other unique products, I want to show which do not match (i.e. A only has sales and D only has returns).

 

I have been doing this by appending the spreadsheets, then pivot and use the Nulls as the exceptions.  But this is not sustaible anymore. 

 

What is the best way to model this?  A many-to-many join? Or a product lookup table of some sort? 

 

What happens with the products also have categories?

 

Thanks for your help.

1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

How about you append the 2 tables, but instead of pivoting the data, simple create a new column called "type". This new column will have the value "sales" or "returns". To do this, load both tables into power query one at a time. Add the new column for each table and hard code the correct value. Then append both tables. 

 

Assuming you then load this data to power pivot, you can then use a pivot table or measures to complete the process. This shape is preferable for power pivot anyway. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

1 REPLY 1
MattAllington
Community Champion
Community Champion

How about you append the 2 tables, but instead of pivoting the data, simple create a new column called "type". This new column will have the value "sales" or "returns". To do this, load both tables into power query one at a time. Add the new column for each table and hard code the correct value. Then append both tables. 

 

Assuming you then load this data to power pivot, you can then use a pivot table or measures to complete the process. This shape is preferable for power pivot anyway. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.