Skip to content

✏️ Exercise 3 - Transform Data – Pivot & Join

Skip

💡 Key Points

  • Pivoting your data allows you to change it from wide to long (columns to rows) or from long to wide (rows to columns) while performing aggregation.
  • You can pivot on multiple fields and use wildcard logic to choose which fields are pivoted.
  • Prior to a join, you can use row deduplication (2024.1) to ensure your data is ready to go.
  • Tableau Prep supports Left, Right, Inner, Left Only, Right Only, Not Inner, and Full join types.

🎯 Your Task

In this exercise, you will use a Pivot Step to denormalize your Shipping data so that the order dates and shipping dates are in two columns rather than rows. The goal is to change the structure of the table as illustrated below:

OrderIDShipping StatusDate
Order AOrdered10/10/2023
Order AShipped12/10/2023

Once the rows are pivoted to columns, this table should look like:
OrderIDOrderedShipped
Order A10/10/202312/10/2023

From there, you will join your Orders and Shipping data together into one unified data set.

📝 Instructions

Exercise 3a - Pivoting Rows to Columns

  • Step 1 Add a Pivot Step after the Shipping Clean Step.
  • Step 2 Pivot the two values in the Shipping Status field (Ordered and Shipped) from rows to columns and select the Date field as the one to aggregate in the corresponding new columns.
  • Step 3 Change the aggregation being performed on the Date field so that it shows an actual date instead of a count of the dates.

Exercise 3b – Joining Orders with Shipping Data

  • Step 1 Inner Join the Orders to the Shipping data by clicking on the Orders Clean Step, dragging and hovering it over the Shipping Pivot step, and dropping it onto the ‘Join’ box when it appears. Your join will be done on the Order ID field.