Forum Discussion

njcgante's avatar
njcgante
Regular Visitor
2 years ago

Power Query merge partially overlapping queries without nulls

I have two queries from two different sources. There are a couple overlapping columns from each that i'm attempting to use to combine them into one table. Basically I need all the info from both in order to do some comparison.  For the sake of discretion, here are sample tables that convey what I'm trying to do:

 

Recipe Table - Used to quantify how much is supposed to be used for each product

ProductIngredientRequired
CakeChocolate5
CakeEgg1
CakeFlour3
CakeSugar1
CakeWater0.5
MuffinCinnamon0.1
MuffinEgg2
MuffinFlour4
MuffinSugar2
MuffinWater0.5

 

Actual Use Data - what the new baker actually used by invoice

InvoiceProductIngredientActual
AMuffinEgg3
AMuffinSugar2
AMuffinWater0.5
BCakeChocolate5
BCakeEgg1
BCakeFlour1
CMuffinChocolate2
CMuffinSugar1
CMuffinWater1

 

End Result I'm looking for:

InvoiceProductIngredientActualRequired
AMuffinCinnamon00.1
AMuffinEgg32
AMuffinFlour04
AMuffinSugar22
AMuffinWater0.50.5
BCakeChocolate55
BCakeEgg11
BCakeFlour13
BCakeSugar01
BCakeWater00.5
CMuffinChocolate20
CMuffinCinnamon00.1
CMuffinEgg02
CMuffinFlour04
CMuffinSugar12
CMuffinWater1

0.5

 

So, I'm trying to create rows for each of the following:

1. Matching data in both tables

2. Ingredients not used that are in the recipe (Actual = null and Required = something)

3. Ingredients used that are not in the recipe (Required = null and Actual = something)

 

I've been able to create #1 & #3 with a left outer join. I've tried multiple combinations of joins and anti-joins to create #2, but have been unsuccessful. No matter what I try, i can't associate an invoice to something with no Actual data. How can I accomplish this?

 

1 Reply

  • The best you can do is a full outer join.

     

    No matter what I try, i can't associate an invoice to something with no Actual data. How can I accomplish this?

     

    Well, it is called Reality for a reason. If there are no actuals then there is no invoice.