Contextures

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.


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

Introduction

Create the pivot table

Clean up the pivot table

Introduction to Multiple Consolidation Ranges

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.

table structure for multiple consolidation

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.

pivot table from multiple consolidation ranges

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.

Pivot Table from Multiple Consolidation Ranges

  1. 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.
  2. Click Multiple consolidation ranges, then click Next

    PivotTable and PivotChart Wizard

  3. Click "I will create the Page Fields", then click Next
  4. Select each range, and click Add
    • Instead of selecting a range on the worksheet, you can use a named 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]
  5. select ranges for multiple consolidation

  6. Click 1 as the number of Page Fields
  7. In the list of ranges, select the first range, and type an item label for that range in the page fields
  8. 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.
  9. page field item labels for multiple consolidation

  10. Click Next
  11. 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.

pivot table from multiple consolidation ranges

Clean Up the 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 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..

  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

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.
  • values changed to Sum

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

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

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.

combine tables in Power Query

To follow this video tutorial, download the sample file from the section below.

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

Get All the Excel News

For regular Excel news, tips, videos, and special offers, please sign up for the Contextures Excel newsletter. Your email address will never be shared with anyone else.

Custom Search

 

 

pivot power free add-in

 

 

pivot power free add-in

 

 



Last updated: September 11, 2016 6:41 PM