Is It Possible To Make Pivot Table Using Multiple Sources Of Data
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.
Note: To see the video transcript, go to the Multiple Sheets Video page.
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.
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.
Pivot Table from Multiple Consolidation Ranges
- 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
- 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]
- 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.
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.
- 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.
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.
- 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.
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 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.
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
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")
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.
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
Is It Possible To Make Pivot Table Using Multiple Sources Of Data
Source: https://www.contextures.com/xlpivot08.html
Posted by: garciagratin.blogspot.com
0 Response to "Is It Possible To Make Pivot Table Using Multiple Sources Of Data"
Post a Comment