Module 02 · Preparing data

Relationships & unions

Relate Sales to the Product and Region tables, then stack Sales_Jul and Sales_Aug.

Step by step8 minLesson 8 of 21 Free

Power BI & Tableau practice fileSales, Product and Region tables, plus July & August data for the append/union exercise. Used in every module of the Power BI and Tableau courses.Excel · ~1,200 rows · free Download

The Sales table only has the ProductID and product name; the category lives in the Product sheet, and each city’s island (Area) lives in the Region sheet. Tableau links tables like these with a relationship: a flexible line often called a "noodle", a bit like VLOOKUP but without copying columns. To stack tables with the same columns, such as Sales_Jul and Sales_Aug, you use a union.

Illustration of the Tableau Data Source page: the Sales table linked by flexible lines to the Product and Region tables, the relationship editor below the canvas showing ProductID = ProductID, and the Union dialog holding Sales_Jul and Sales_Aug. Zoom
A relationship links tables through a key column; a union stacks tables with the same columns. This picture sums up two steps: in step 4 the Union dialog is opened in a second data source.

Click a number on the picture or in this list to highlight that area.

Step by step

  1. Step 1: Click the Data Source tab at the bottom left. From the Sheets list on the left, drag Product onto the canvas, to the right of the Sales table. Tableau draws a flexible line (the "noodle", number 1) and tries to match columns with the same name.

    Tip: Click the noodle to open the relationship editor (number 2). Make sure it reads ProductID (Sales) = ProductID (Product); if not, pick the columns from the dropdowns. Leave Performance Options at their defaults.

  2. Step 2: From the Sheets list, also drag the Region sheet onto the canvas and drop it near Sales (not Product), so the noodle starts from Sales. In the relationship editor, match the Region column on both sides; on the Sales side it may read Region (raw) because you renamed it in the previous lesson.

    Tip: Joins exist too: double-click a table on the canvas to open the layer inside it. Tableau recommends relationships as the default because they don’t duplicate rows.

    Watch out: A relationship matches the original column values, not your group. The "Bandung " rows (with the space) find no partner in the Region table, so their Area shows as Null. The permanent fix belongs in the source file.

  3. Step 3: Open a new sheet (the New Worksheet icon). The Data pane now shows three tables: Sales, Product and Region. Drag Category (under the Product table) to Rows and Revenue (under the Sales table) to Columns, then click Sort Descending on the toolbar.

    Tip: Fields with the same name in two tables get the table name as a suffix, e.g. ProductID (Product). For cities, keep using Region with the paperclip icon (your group), not the Region field from the Region table.

  4. Step 4: Build the union in a new data source so the Sales data source you tidied stays as it is: Data → New Data Source → Microsoft Excel → pick insyntive-sales-sample.xlsx again. On the Data Source page, double-click New Union (below the Sheets list), drag Sales_Jul and then Sales_Aug from the Sheets list into the Union window (number 3), then click OK.

    Tip: Tableau adds Sheet and Table Name columns that record where each row came from, so you can still tell July orders from August orders.

    Watch out: A union only lines up neatly when column names and types match. Columns without a partner are filled with Null.