Mastering Pivot Tables: Combine Multiple Tables

In the realm of data analysis, the ability to consolidate and manipulate data from multiple sources is a crucial skill. One of the most powerful tools for this purpose is the pivot table, a feature available in spreadsheet software like Microsoft Excel and Google Sheets. But can you create a pivot table that draws data from multiple tables? The short answer is yes, and this article will guide you through the process.

Pivot Tables Exercises
Pivot Tables Exercises

Before we dive into the steps, let's understand why you might need to create a pivot table with multiple tables. Often, data is stored in different tables to maintain data integrity and prevent redundancy. However, to gain insights, you might need to combine and analyze this data. This is where pivot tables come in, offering a flexible way to summarize, analyze, explore, and present large amounts of data.

Unlock the Power of Pivot Tables
Unlock the Power of Pivot Tables

Preparing Your Data

Before creating a pivot table, ensure your data is clean and well-structured. Each table should have a unique header for each column, and there should be no blank rows or columns. Also, ensure that the tables are related to each other through a common field, such as a customer ID or order ID.

Multi-level Pivot Table in Excel
Multi-level Pivot Table in Excel

For this example, let's assume you have two tables: 'Orders' and 'OrderDetails'. The 'Orders' table contains order IDs, customer IDs, and order dates. The 'OrderDetails' table contains order IDs, product IDs, quantities, and prices.

Combining Your Tables

a blue and white poster with the words which pivot table to use on it
a blue and white poster with the words which pivot table to use on it

To create a pivot table that uses data from multiple tables, you first need to combine these tables. This can be done using a VLOOKUP, INDEX MATCH, or a database query (if you're using a database management system). For simplicity, let's use the VLOOKUP function in Excel.

Using VLOOKUP

The VLOOKUP function allows you to search for a value in the first column of a table, and then return a value in the same row from a column you specify. In our case, we'll use the order ID to combine the 'Orders' and 'OrderDetails' tables.

a man standing in front of a sign that says how to connect slices to multiple excel pivot tables
a man standing in front of a sign that says how to connect slices to multiple excel pivot tables

Assuming your 'Orders' table is in Sheet1 (A1:B10) and your 'OrderDetails' table is in Sheet2 (A1:E10), enter the following formula in a new sheet (e.g., Sheet3):

=VLOOKUP(A2, Sheet2!A:E, {2,3,4,5}, FALSE)

This formula looks up the order ID in Sheet2 (column A), and returns the corresponding values from columns B, C, D, and E. The 'FALSE' at the end of the formula ensures that the formula returns an exact match, not an approximate one.

Transform Your Excel Skills with Multi-Sheet Pivot Tables
Transform Your Excel Skills with Multi-Sheet Pivot Tables

Creating the Pivot Table

Once you've combined your tables, you can create a pivot table. Select the data range, then go to 'Insert' > 'PivotTable'. Choose where you want to place the pivot table, then click 'OK'.

a table that has different types of items and numbers on it, with the words which pivot table to use
a table that has different types of items and numbers on it, with the words which pivot table to use
Pivot Table Pro - 101 Expert Examples
Pivot Table Pro - 101 Expert Examples
The 6-In-1 Table That Can Do It All. Modern Dining Room Furniture
The 6-In-1 Table That Can Do It All. Modern Dining Room Furniture
How to make and use Pivot Table in Excel
How to make and use Pivot Table in Excel
the pivot table basics info sheet is shown in green and white, with instructions for each
the pivot table basics info sheet is shown in green and white, with instructions for each
Multi-Select Slicer Items In Microsoft Excel Pivot Tables
Multi-Select Slicer Items In Microsoft Excel Pivot Tables
Automatically Refresh a Pivot Table | MyExcelOnline
Automatically Refresh a Pivot Table | MyExcelOnline
50 Things You Can Do With Excel Pivot Table | Free Microsoft Excel Tutorials
50 Things You Can Do With Excel Pivot Table | Free Microsoft Excel Tutorials
The Ultimate Guide To  An Excel Pivot Table | MyExcelOnline
The Ultimate Guide To An Excel Pivot Table | MyExcelOnline
the pivot table tricks work smarter, not harder info sheet is shown in green
the pivot table tricks work smarter, not harder info sheet is shown in green
How to Combine Data From Pages in Excel
How to Combine Data From Pages in Excel
How to make pivot tables in r with multiplot function -  part 2
How to make pivot tables in r with multiplot function - part 2
the flow diagram shows how to do an excel pivot table
the flow diagram shows how to do an excel pivot table
the power pivot in excel with data visualization and total sales data, as well as
the power pivot in excel with data visualization and total sales data, as well as
the words pivots from multiple tables are shown in grey on a yellow background
the words pivots from multiple tables are shown in grey on a yellow background
the top pivot table tips and shortcuts are shown in this chart,
the top pivot table tips and shortcuts are shown in this chart,
10 Expert Level PIVOT TABLE TRICKS you cannot miss! 🤩
10 Expert Level PIVOT TABLE TRICKS you cannot miss! 🤩
How to Create a Pivot Table in Excel - Tutorial
How to Create a Pivot Table in Excel - Tutorial
an advertisement for excel finance with the words, 100k + people watched this pivot table trick learn it in under 3 minutes
an advertisement for excel finance with the words, 100k + people watched this pivot table trick learn it in under 3 minutes
the pivot table reports logo on an orange, green and white background with text
the pivot table reports logo on an orange, green and white background with text

In the 'PivotTable Fields' pane, drag and drop the fields you want to use in your pivot table. For example, you might want to use 'Order Date' for rows, 'Product ID' for columns, and 'Quantity' and 'Price' for values. You can also add 'Customer ID' to the 'Rows' area to see order data by customer.

With these steps, you've successfully created a pivot table that draws data from multiple tables. This table allows you to analyze your data in a way that wasn't possible with the individual tables alone.

Updating Your Pivot Table

One of the benefits of using pivot tables is that they update automatically when new data is added. However, you need to ensure that your combined table is updated as well. If you're using VLOOKUP, you can simply drag the formula down to include new rows. If you're using a database query, you'll need to refresh the query.

Refreshing Your Pivot Table

To refresh your pivot table, right-click anywhere in the pivot table and select 'Refresh'. This will update the pivot table with any new data in your combined table.

Remember, the key to a successful pivot table is clean, well-structured data. Always ensure that your data is in the best possible shape before creating a pivot table.

Now that you know how to create a pivot table with multiple tables, you can explore and analyze your data in ways you never thought possible. Happy pivoting!