Join Two Tables

It is possible to join two separate tables together in CODAP by an attribute/column that both tables share in common. To do so, drag the name of the column you wish to join on from one table and place it on top of the name of the column in the other table you wish to join on. This will bring all the other columns/attributes from the first table into the second table, with the newly added columns/attributes highlighted in yellow.

The GIF below shows an example of joining two tables together. Here, both the "Domestic House Cats" and "Owners" tables have an attribute titled "Owner name." Dragging the "Owner name" column heading from the "Owners" table and dropping it on the "Owner name" heading in the "Domestic House Cats" table joins the two tables together, taking the "Owner home type" column/attribute from the "Owners" table and adding it to the "Domestic House Cats" table. Note that this join works even though some owners have multiple cats--in the example below, for instance, an "Owner home type" value of "apartment" is added to each of the three cats owned by Liliana. Note also that the join works even hough there is an owner named Jan who is present in the "Domestic House Cats" table but not in the "Owners" table. Because Jan is not in the "Owners" table, no value for "Owner home type" is added for Jan in the "Domestic House Cats" table upon joining with the "Owners" table.

Note that the reason the added "Owner home type" column in the "Domestic House Cats" table is highlighted in yellow is that it is calculated by a "lookupByKey" formula. One can perform joins manually with greater control using the formula editor (for example, to bring in just one column/attribute from the other table rather than all of them). If you wish to delete the table/column referenced in the formula, make sure to first click on the header of the calculated attributed and select "Delete Formula (Keeping Values")--otherwise, you will end up with an empty column.

In this particular example, it is important to do the joining by bringing "Owner home type" from the "Owners" table to the "Domestic House Cats" table. The GIF below illustrates the problems that arise if one makes the join in the other direction. Because there is only one case for each owner in the "Owners" table, the information for just one cat for each owner is imported. Some owners, however, have multiple cats, but it is impossible to know this or see the information for more than one cat per owner when the join is done going from "Domestic House Cats" to "Owners." Note that in the example below, there is a person in the "Owners" table (Jordan) who is not present in the "Domestic House Cats" table--therefore, when the data from "Domestic House Cats" is joined with "Owners," there are no values pertaining to cats owned by Jordan.

One final note: It is best to make sure you have no duplicated rows in either table before joining them together.

Was this Article Useful?