Pivot Tables > Create > Multiple Sources
Pivot Table Multiple Consolidation RangesCreate a Pivot Table using data from different sheets in a workbook, or from different workbooks, if those tables have identical column structures. Also, see alternatives to multiple consolidation ranges, by using Power Query or a Union Query. Author: Debra Dalgleish |
Create Pivot Table from Multiple SheetsTo create a Pivot Table in Microsoft Excel, you can use data from different sheets in a workbook, or from different workbooks. Use one of the following 3 methods - Multiple Consolidation Ranges, Power Query or a Union Query. 1) Multiple Consolidation RangesIf you have an older version of Excel, without Power Query, you can use this method. However, all the tables must have the same column structure, and the pivot table has limitations.
Note: If possible, move your data to a single worksheet, or store it in a database, such as Microsoft Access, and you'll have more flexibility in creating the pivot table. 2) Power QueryThis is the best option, if your version of Excel has either Power Query, or Get & Transform Data
3) Union QueryThis is a good option, in older versions of Excel, using the MS Query tool.
|
Pivot Table Multiple Consolidation RangesTo create a pivot table from different sheets in a workbook, or from different workbooks, you can use the Pivot Table Multiple Consolidation Ranges feature. First, here are two important limitations to keep in mind, before you start:
The video below shows the steps, and there are written instructions below the video. -- Video: Pivot Table from Multiple Sheets -- Limitations of multiple consolidation ranges Also, see the Alternatives to Multiple Consolidation Ranges, in the sections further down on this page Video: Pivot Table from Multiple SheetsTo see how to create a pivot table from data on different sheets, watch this short video. The written instructions are below. Note: To see the full video transcript, go to the Multiple Sheets Video page. |
Step 2a - PivotTable and PivotChart WizardIn Step 2a, follow these steps:
Step 2b - PivotTable and PivotChart WizardIn Step 2b, follow these steps, to add the first range that you want to use for the pivot table:
Range Selection Tips:
|
Number of Page FieldsCreating Page Fields is optional, but setting up one or more page fields will allow you to filter the pivot table later, based on each range that you add to the pivot table. In this example, we'll create one page field, so the data can be filtered by region - East, West or both.
Note: See the notes below, for an example of using more than one page field. Page Field Item LabelsAfter you add each range, follow these steps, so create an item label for it, in the page field.
In the screenshot below, the range on the West sheet is selected, and the item label, "West" has been entered for that range. Add All the Remaining RangesAfter the first range has been added, and you created page field labels for it:
Finally, after all the ranges have been entered:
|
Step 3 - PivotTable and PivotChart WizardThe final step is to select a location for the PivotTable. 1) For the first question, choose where you want to put the pivot table:
1b) If you selected Existing worksheet, follow these steps next:
2) Finally, click the Finish button, to create the pivot table Review the Pivot TableA pivot table appears on the worksheet, with the following layout:
Tip: For suggestions on how to make this pivot table look better, and easier to use, continue down to the Clean Up the Pivot Table section below |
Multiple Page FieldsInstead of using only one page field, you could create 2, 3 or 4 pages, if needed. Based on the data ranges that you're adding, how would you want to filter the pivot table later? For example, perhaps you have 4 different sheets, with sales data from:
In that case, you could create 2 pages: Region and Year Then, create 2 field labels for each range, so they can be filtered by region or year:
|
Change the LabelsIn the pivot tables, generic fields are created -- Row, Column, Value and Page1. You can rename those fields, to make the pivot table easier to understand.
The labels have been changed in the screen shot shown below. The Column Labels heading was replaced by a space character. Change the LayoutBy default, the pivot table has the Compact Report Layout, and you can change that to Outline, so each Row field will be in a separate column. Then, move the Page field into the Row area, above the existing Row field.
|
Limitations of Multiple ConsolidationWhen you create a pivot table from multiple consolidation ranges, the pivot table has the following limitations:
To help you work within these limitations, I've put a few suggestions below. Before You Build the Pivot TableTo get the best results from a multiple consolidation ranges pivot table, try these suggestions for optimizing your source data layout:
After You Build the Pivot TableTo improve a multiple consolidation ranges pivot table, try these suggestions for optimizing its layout:
|
Alternatives to Multiple ConsolidationTo avoid the limitations of multiple consolidation ranges, you can combine the source data into a single table, using one of the following methods. -- Power Query -- Union Query Then, build a pivot table from the combined tables Combine Tables With Power QueryIf you have a version of Excel that supports Microsoft's Power Query add-in, you can use it to combine the data in two or more tables. The tables can be in the same workbook, or in different files. The tables can have different structures, and should have some columns with identical headings, in which the data can be combined. In this example, the East and West region data will be combined, and one column is unique in each table. Go to the Combine Tables with Power Query page for written instructions, and the sample file. To follow this video tutorial, go to the Combine Tables with Power Query page and download the sample file with East and West sales data. |
Create a Union QueryIf you can't combine your data on a single worksheet, another solution is to create named ranges in an Excel file, and use Microsoft Query (MS Query) to combine the data. Union Query Macro -- Sheets in One File Union Query Macro -- Data in Multiple Excel Files Create a Union Query ManuallyIn Excel, you can open the Microsoft Query tool, and write a SQL statement to create a Union query (full outer join) to combine multiple tables. Then, use the result as the pivot table's source data. To see an example, download the Union Query sample files. It has a query that was built manually, and has a button to refresh the data. With this solution, you'll end up with a normal pivot table, with none of the limitations. However, it's a bit tedious to set up, especially if you have more than a couple of tables. You can read more about MS Queries here:
Union Query Macro -- Sheets in One FileInstead of manually setting up a union query, you can use the code in a sample file from Excel MVPs, Kirill Lapin (KL), with amendments by Hector Miguel Orozco Diaz. |
1. Change the Sheet NamesBefore you use the sample code, replace the sample sheet names with the sheet names in your workbook. For example, if your sheet names are "East" and "West", change this line of code:
to this
2. Change the Pivot Table LocationIn the code, you can also change the location where the pivot table will be added. In the sample file, the TableDestination is set for the active sheet, in range A1. 3. Run the MacroThen, after you make those small changes, click the button on the worksheet, and a summary pivot table is automatically created. Union Query Macro -- Data in Multiple Excel FilesIf you need to combine data in multiple files, here are a couple of options, using macros provided by Excel expert, Kirill Lapin. Pivot Table - The first example works on multiple files, which must have the data in identical structures, and you can read the instructions on my blog. To see Kirill's pivot table code, you can download the Pivot Workbooks example. The zipped folder that contains the Report.xls file, and the five sample data files. Unzip the folder, and keep all the files in the same folder. When you open the Report.xls file, enable macros to run the code. Pivot Table or Excel Table - Select two or more files which have lists in an identical structure, and the code in this workbook will automatically create a pivot table or Excel table from all the data. Read the details in blog post, Create a Pivot Table from Multiple Files. Click here to download the sample files. |
Download the Sample FileDownload the sample pivot table tutorial file Related Articles |
Last updated: March 8, 2023 7:29 PM