How to Perform Cross Join

This note introduces how to perform a cross join using two data frames. For example, by using two data frames where each row contains unique values, performing a cross join makes it possible to create data with all combinations of values.

Data

This time we will use two data frames as follows:

Product Data

Color Data

1. Create dummy join keys in both data frames

Since these two datasets do not have a common key, it is impossible to join them with the current data as is. Therefore, when performing a cross join, we add dummy columns containing the same values to all rows in each data frame, and perform a left outer join using those dummy key columns.

First, let’s add a dummy join key column to the product data frame. Select “Create Calculation” -> “Standard”from any column header menu.

When the Create Calculation dialog appears, type any number or character. (In this case, we are typing the number “1”) At this time, check “Create new column”, set any column name, and run.

The dummy key column has been created.

Since we need to perform exactly the same process on the color data frame, copy the step that added the dummy key column.

Once the step is copied,

move to the color data frame and paste the step.

We have successfully added a dummy key column to the color data frame as well.

2. Perform left outer join using the dummy join key

Now that we have added dummy key columns to both data frames, move to the product data frame and select “Join (Add Columns/Join)” from the “dummy_key” column header menu.

Select “Left Outer Join (Left Join)” as the join type, select the target data frame for joining, and execute. Note that since the dummy key columns have the same column name in both data frames, the join key column for the target is automatically selected.

We have successfully created all combinations of products and colors.

Export Chart Image
Output Format
PNG SVG
Background
Set background transparent
Size
Width (Pixel)
Height (Pixel)
Pixel Ratio