Chapter 32. Completing Advanced Joins
Joining is one of the more powerful techniques for preparing your data for analysis. Adding another data set to your existing data can either give you more context about why something is happening or answer more granular questions. In Chapter 16 we covered using join types and join conditions to get to the data you want in a straightforward way. However, as you’ll see in this chapter, there are many use cases for joins where the logic is more complex.
Multiple Join Conditions
Frequently, the process of linking two data sets will require more than a simple, single join condition. When using multiple join conditions, keep in mind that they behave as an AND rather than an OR statement. In other words, for the data record being assessed to be output by the inner section of a Join step, every join condition must be met.
In the example challenge, Preppin’ Data 2020: Week 8, joining the Actual Volume and Value data set (Figure 32-1) to the Profit data set (Figure 32-2) requires multiple join conditions.
Figure 32-1. Actual Volume and Value data set
Figure 32-2. Profit data set
Each data set has only 16 rows of data, but with just one join condition (Type), the output of the join is 128 rows (Figure 32-3).
Figure 32-3. Duplication of rows caused ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access