Search Contextures Sites
Create a Pivot Table using data from different sheets in a workbook, or from different workbooks, if those tables have identical column structures.
- Create a Pivot Table from Data on Different Sheets
- Create a pivot table from multiple consolidation ranges
- Clean up a Multiple Consolidation Pivot Table
- Video: Create a Pivot Table from Multiple Sheets
- Limitations of multiple consolidation ranges
- Alternatives to Multiple Consolidation Ranges
- Download the Sample File
- Excel Pivot Table Tutorial List
To create a Pivot Table, you can use data from different sheets in a workbook, or from different workbooks, if those tables have identical column structures.
However, you won't get the same pivot table layout that you'd get from a single range, as you can see in the screen shot below.
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.
If combining your data isn't an option, this pivot table tutorial explains the steps to create a pivot table from multiple consolidation ranges, describes the limitations, and suggests workaround solutions.
- To open the PivotTable and PivotChart Wizard, select any cell on a worksheet, then press Alt+D, then press P. That shortcut is used because in older versions of Excel, the wizard was listed on the Data menu, as the PivotTable and PivotChart Report command.
- Click Multiple consolidation ranges, then click Next
- Click "I will create the Page Fields", then click Next
- Select each range, and click Add
- Click 1 as the number of Page Fields
- In the list of ranges, select the first range, and type an item label for that range in the page fields
- Repeat for the remaining ranges. In the screen shot below, the range on the West sheet is selected, and the item label, "West" has been entered for that range.
- Click Next
- Select a location for the PivotTable, then click Finish
A pivot table appears on the worksheet, with the first field in the Row area, and all of the other fields from the source data in the Values area, showing a Count.
All of the fields from the source data are included in the multiple consolidation pivot table, so you can remove some of them, and make a few other changes.
Remove fields that don't contain meaningful data
In this example, the Colour, Date, Price and Rep fields contain text, or numbers that are meaningless in this report, so they will be removed.
- Click the drop down arrow in the Column Labels heading
- Remove the check marks for fields that you want to remove.
- Click OK
Change the Value Field Calculation
By default, the Values will show as Count, and you can change that to Sum, or another calculation.
NOTE: This will affect all of the Values -- they cannot be changed separately.
- Right-click one of the Values
- Point to Summarize Values By, and click on Sum.
Remove the Grand Total for Rows
The Grand Total for Rows is meaningless in this report, because it is showing the total for unrelated items, so it should be removed..
- Right-click on the heading for the Grand Total for Rows
- Click Remove Grand Total.
Change the Labels
In 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.
- Click on any label in the pivot table, and type a new label, then press Enter
- For example, click on the Page1 label, type Region, and press Enter
The labels have been changed in the screen shot shown below. The Column Labels heading was replaced by a space character.
Change the Layout
By 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.
- Select any cell in the pivot table
- On the Ribbon, under PivotTable Tools, click the Design tab.
- In the Layout group, click Report Layout, then click Outline Form
- In the PivotTable Field List, drag the Page1 field from the Filters area, into the Row area, above the existing Row field.
- Change the Row Field to Item, now that it is in a separate column.
To see the steps for creating a pivot table from data on different sheets, what this multiple consolidation ranges pivot table video tutorial.
In this example, Item is the first column in the data source, and the pivot table row heading shows the item names. Remaining fields are shown in the column area.
- The Pivot Table contains some meaningless data, such as sum of Date and columns full of zeros where the database columns contain text. Remove those fields, as described in the section on Clean Up the Pivot Table, above.
- You can change the function (e.g. SUM) that is being used by the data value, but it will use the same function on all these columns.
- The first column in the source data is always added to the Row area in the pivot table.
- To get the best results, rearrange your database columns, so the most important column is at the far left. That column of data will become the Row values in the pivot table.
- If there are columns that you don't want in the pivot table, move those to the far right in the source data. Then, do not include those columns when selecting the data ranges for the pivot table.
To avoid the limitations of multiple consolidation ranges, you can try one of the following alternatives.
If 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.
To follow this video tutorial, download the sample file from the section below.
Manually Create a Union Query
If 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. There are sample files here: http://www.contextures.com/excelfiles.html#PT0007
Then, use the Union query (full outer join) result as the pivot table's source 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:
- Description of the usage of joins in Microsoft Query
- Use Wildcard Characters in Microsoft Excel 2000 Parameter Queries
Instead 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 Héctor Miguel Orozco Diaz.
Before 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:
arrSheets = Array ("Ontario", "Alberta")
arrSheets = Array ("East", "West")
In 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.
Then, after you make those small changes, click the button on the worksheet, and a summary pivot table is automatically created.
To download the sample file from Kirill and Héctor, click here: Pivot Table From Multiple Sheets.
Kirill Lapin shares his code to create a Union query and build a fully functional pivot table from data in multiple Excel files. For instructions, read the Contextures Pivot Table Blog article:
There also an example file that creates either a pivot table or a formatted Excel table from the consolidated data. Download it from the Excel Sample Files page, in the Pivot Tables Section:
Download the sample pivot table tutorial file
For regular Excel news, tips and videos, please sign up for the Contextures Excel newsletter. Your email address will never be shared with anyone else.
- Pivot Table Introduction
- Grouping Data
- Pivot Table from Multiple Sheets
- Running Totals
- Summary Functions
- Clear Old Items in Pivot Table Drop Downs
Contextures Inc., Copyright ©2015
All rights reserved.
Last updated: January 20, 2015 7:38 PM