Contextures
Pivot Tables > Create > Multiple Sources

Pivot Table Multiple Consolidation Ranges

Create 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 Sheets

To 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 Ranges

If 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.

  • Versions: Available in any version of Excel
  • Pivot Table: Creates a pivot table with only 4 fields, and limited flexibility.
  • Instructions: Go to the Multiple Consolidation Ranges section below, to see a video, and step-by-step instructions

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 Query

This is the best option, if your version of Excel has either Power Query, or Get & Transform Data

  • Versions: Only for versions of Excel that support Power Query, or Get & Transform Data
  • Pivot Table: Creates a pivot table with all fields from source data, and full flexibility.
  • Instructions: Go to the Power Query section below, to see a video, and to get the link for step-by-step instructions

3) Union Query

This is a good option, in older versions of Excel, using the MS Query tool.

  • Versions: Available in any version of Excel
  • Pivot Table: Creates a pivot table with all fields from source data, and full flexibility.
  • Instructions: Go to the Union Query section below, to see step-by-step instructions, and to download the sample files

Pivot Table Multiple Consolidation Ranges

To 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:

  • This method only works if all of the lists have identical column structures.
  • The pivot table layout has many limitations, compared to a normal pivot table

The video below shows the steps, and there are written instructions below the video.

-- Video: Pivot Table from Multiple Sheets

-- Create the pivot table

-- Clean up the pivot table

-- 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 Sheets

To 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.

Pivot Table from Multiple Consolidation Ranges

To create a pivot table from data on different sheets, or in different workbooks, follow the steps below.

Check Your Data

This method only works if all of the data lists or tables have identical column structures.

  • Check all of the lists that you want to use in the pivot table, and adjust their column structure, if necessary

table structure for multiple consolidation

Start the Pivot Table

  • First, select any cell on a worksheet - you don't need to select a cell in one of the lists
  • Next, to open the PivotTable and PivotChart Wizard, use this keyboard shortcut:
    • Press Alt+D, then tap the P key
    • In older versions of Excel, the wizard was listed on the Data menu, as the PivotTable and PivotChart Report command.
  • The PivotTable and PivotChart Wizard opens, showing Step 1 of 3.

Step 1 - PivotTable and PivotChart Wizard

In Step 1, follow these steps:

  • In the first section, Where is the data that you want to analyze?, select the Multiple consolidation ranges option (or use the keyboard shortcut, Alt+C)
  • In the second section, What kind of report do you want to create?, select the PivotTable option (or use the keyboard shortcut, Alt+T)
  • Then, click Next, to go to Step 2a

PivotTable and PivotChart Wizard

 

Step 2a - PivotTable and PivotChart Wizard

In Step 2a, follow these steps:

  • Under the question, How many page fields do you want?, select the option, I will create the Page Fields.
  • Then, click Next, to go to Step 2b

Step 2a in PivotTable and PivotChart Wizard

Step 2b - PivotTable and PivotChart Wizard

In Step 2b, follow these steps, to add the first range that you want to use for the pivot table:

  • At the top of Step 2b, click in the Range box
  • Next, click on Excel in the background
  • Go to the first data range that you want to use for the pivot table
  • Select all the cells in that data range, including all the heading cells and all the data cells
  • The range address will appear in the Range box, showing the sheet name, and an absolute reference to the cells.
  • Click the Add button, to add that range to the All Ranges list (do not click the Next button yet).

Range Selection Tips:

  • Instead of selecting a range on the worksheet, you can type the name of range, such as EastData.
  • If the source data is in a named Excel table, you can refer to that table, using its name and [#All]. For example: Table2[#All]

select ranges for multiple consolidation

Number of Page Fields

Creating 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.

  • For the question, How many page fields do you want?, select 1

Note: See the notes below, for an example of using more than one page field.

number of page fields

Page Field Item Labels

After you add each range, follow these steps, so create an item label for it, in the page field.

  • In the All ranges list, click on a range, to select it
  • In the Item labels section, click in the Field One box
  • Type a label that identifies the selected region.
    • Note: If you are using multiple pages, type a label for the selected range in each of the Field boxes

In the screenshot below, the range on the West sheet is selected, and the item label, "West" has been entered for that range.

page field item labels for multiple consolidation

Add All the Remaining Ranges

After the first range has been added, and you created page field labels for it:

  • Repeat the steps to add all the remaining ranges.
    • Be sure to include headings and all the data for each range
  • For each range, enter a page field label that will make it easy to identify later, in the page filter's drop down list.
    • In the screen shot below, the pivot table page filter shows East and West items.
    • number of page fields

Finally, after all the ranges have been entered:

  • Click the Next button, to go to Step 3.

Step 3 - PivotTable and PivotChart Wizard

The final step is to select a location for the PivotTable.

1) For the first question, choose where you want to put the pivot table:

  • New worksheet, OR
  • Existing worksheet

1b) If you selected Existing worksheet, follow these steps next:

  • Click in the location box, then click on Excel in the background
  • Go to the sheet where you want the pivot table
  • Click on the cell where you want the pivot table to start
  • The sheet name and address will appear in the location box

2) Finally, click the Finish button, to create the pivot table

number of page fields

Review the Pivot Table

A pivot table appears on the worksheet, with the following layout:

  • First field from source data ranges is in the Row area, with item names listed there
  • All other fields from the source data are in the Values area
  • All Value fields show a Count of items, even if the values in that field are numeric.

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

pivot table from multiple consolidation ranges

Multiple Page Fields

Instead 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:

  • east and west regions
  • the past 2 years.

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:

  • East 2021 - Region: East, Year: 2021
  • West 2021 - Region: East, Year: 2022
  • East 2022 - Region: West, Year: 2021
  • West 2022 - Region: West, Year: 2022

Clean Up Multiple Consolidation Pivot Table

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.

  1. Click the drop down arrow in the Column Labels heading
  2. Remove the check marks for fields that you want to remove.
  3. Click OK

    remove values from multiple consolidation pivot table

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.

  1. Right-click one of the Values
  2. Point to Summarize Values By, and click on Sum.

change the value field calculation

Remove 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..

  1. Right-click on the heading for the Grand Total for Rows
  2. Click Remove Grand Total.

remove grand total for rows

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.

  1. Click on any label in the pivot table, and type a new label, then press Enter
  2. 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.

remove values from multiple consolidation pivot table

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.

  1. Select any cell in the pivot table
  2. On the Ribbon, under PivotTable Tools, click the Design tab.
  3. In the Layout group, click Report Layout, then click Outline Form
  4. In the PivotTable Field List, drag the Page1 field from the Filters area, into the Row area, above the existing Row field.
  5. Change the Row Field to Item, now that it is in a separate column.

remove values from multiple consolidation pivot table

Limitations of Multiple Consolidation

When you create a pivot table from multiple consolidation ranges, the pivot table has the following limitations:

  • Only one field can show its items in the Row area
    • You can't select a field for the row area -- the first column from the source data is automatically selected
  • All other fields are added to the Values area
    • Their names are shown across the top of the pivot table, as column headings
  • All value fields use the same calculation, such as Sum or Count.

To help you work within these limitations, I've put a few suggestions below.

Before You Build the Pivot Table

To get the best results from a multiple consolidation ranges pivot table, try these suggestions for optimizing your source data layout:

  • 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.

After You Build the Pivot Table

To improve a multiple consolidation ranges pivot table, try these suggestions for optimizing its layout:

  • Remove any meaningless data, such as columns full of zeros, for text data.
  • values changed to Sum

  • By default, the values are shown as Count. Choose a different function, if applicable, such as Sum
    • NOTE: The selected function will be applied to all the Values
  • Change the Page field names, from Page1 to something meaningful
  • Move Page fields into the Row area, to group the data based on the page items
    • In the screen shot below, Region is a page field, and Item is the first column in the source data.

remove values from multiple consolidation pivot table

Alternatives to Multiple Consolidation

To 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 Query

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.

Go to the Combine Tables with Power Query page for written instructions, and the sample file.

combine tables in Power Query

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 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.

Create a Union Query Manually

Union Query Macro -- Sheets in One File

Union Query Macro -- Data in Multiple Excel Files

Create a Union Query Manually

In 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.

pivot union query

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 File

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 Hector Miguel Orozco Diaz.

1. Change the Sheet Names

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")

to this

  • arrSheets = Array ("East", "West")

pivot multiple sheets code

2. Change the Pivot Table Location

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.

pivot multiple sheets location

3. Run the Macro

Then, 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 Files

If 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 File

Download the sample pivot table tutorial file

Related Articles

Unpivot, Power Query

About Debra

 

Last updated: March 8, 2023 7:29 PM