PivotTables are great for analyzing and reporting on your data. And when your data happens to be relational—meaning it's stored in separate tables you can bring together on common values—you can build a PivotTable.
What’s different about this PivotTable? Notice how the Field List on the right shows not just one but a collection of tables. Each of these tables contain fields you can combine in a single PivotTable to slice your data in multiple ways. No manual formatting or data preparation is necessary. You can immediately build a PivotTable based on related tables as soon as you import the data.
Here are the three basic steps to get multiple tables into the PivotTable Field List:
Step one: import related tables from a database
Import from a relational database, like Microsoft SQL Server, Oracle, or Access. You can import multiple tables at the same time:
-
Connect to an Oracle database You might need to install additional client software. Check with your database administrator to find out if this is required. Note Not supported on Excel for Mac.
-
Connect to an Access database For more information, see Tutorial: Import Data into Excel, and Create a Data Model for details. Note Not supported on Excel for Mac.
-
Connect to an IBM DB2 database Note Not supported on Excel for Mac.
-
Connect to a MySQL database Note Not supported on Excel for Mac.
Step two: add fields to the PivotTable
Notice that the Field List contains multiple tables.
These are all of the tables that you selected during import. You can expand and collapse each table to view its fields. As long as the tables are related, you can create your PivotTable by dragging fields from any table to the VALUES, ROWS, or COLUMNS areas. You can:
-
Drag numeric fields to the VALUES area. For example, if you are using an Adventure Works sample database, you might drag SalesAmount from the FactInternetSales table.
-
Drag date or territory fields to the ROWS or COLUMNS area to analyze sales by date or territory.
Step three: optionally create relationships
Sometimes you need to create a relationship between two tables before you can use them in a PivotTable. If you get a message indicating a relationship is needed, click Create to get started.
Note Data Models are not supported on Excel for Mac.
Relational databases are not the only data source that lets you work with multiple tables in a PivotTable Field List. You can use tables in your workbook or import data feeds that you then integrate with other tables of data in your workbook. For more information, see Import multiple tables from other data sources.
To make all this unrelated data work together, you’ll need to add each table to the Data Model, and then create relationships between the tables using matching field values. For more information, see Add worksheet data to a Data Model using a linked table, Create a relationship between two tables, and Create relationships in Diagram View.
After you’ve created a Data Model, you can use this data in your analysis. Here's how you build a new PivotTable or PivotChart using the Data Model in your workbook.
-
Click any cell on the worksheet.
-
Select Insert, and then the down arrow under PivotTable.
-
Select From External Data Source.
-
Select Choose Connection.
-
On the Tables tab, in This Workbook Data Model, select Tables in Workbook Data Model.
-
Click Open, and then click OK to show a Field List containing all the tables in the Data Model.