Home > Topics > excel > body text

Excel case sharing: Use Powerquery to merge multiple sheets with one click

青灯夜游
Release: 2022-09-19 11:06:37
forward
9751 people have browsed it

Excel case sharing: Use Powerquery to merge multiple sheets with one click

After sharing Power Query merging worksheets with you last time, many friends left messages asking what should be done if there is an increase or decrease in worksheets? Today I will introduce to you how to use Power Query to merge workbooks, so that no matter the worksheet changes or data changes in the workbook, you can refresh the summary with one click. Come and learn now!

Those who did not learn the last tutorial should learn the previous one first. Click to view: "Excel Case Sharing: Using Power Query to Implement Multi-Table Merger"

As shown in the figure, there are four worksheets under the workbook, which list the sales data of four cities respectively.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

First create a new workbook, open the [Acquisition and Conversion] group under the Data tab, click New Query---From File---From Workbook.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

In the import data window, find the location of the workbook, select the workbook, and click Import.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

Check "Multiple Select" in the navigator window and check the four worksheets below.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

You can also directly select the workbook (the 4 at the end indicates that the workbook has four worksheets) and click Edit.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

This will enter the Power Query editor interface introduced before. The top is the menu bar, the middle is the table area and the data that will be returned to the worksheet at the end. The query setting window on the right displays the Power Query operation record.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

The table area displayed in the middle displays the information of the data source workbook. The "Name" column is the name of the worksheet contained in the workbook, where "Data" This column is in green font, which means that each cell contains a Table. Click the cell to preview the content inside (note: when the mouse is placed on the text and turns into a palm shape, the file in the cell is opened to generate a new step. If you need to preview, just click elsewhere in the cell. ). The content of this Table appears in the preview pane below, which is the data we want to summarize.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

#What we need to do now is to extract and merge all the Tables in the "Data" column.

Click the expand button in the upper right corner of Data and select to expand all columns in the drop-down window. This "Use original column name as prefix" is generally not checked, click OK.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

#In this way, all the contents of the worksheets in the workbook are summarized in the table. A new step appears in the query settings window on the right. When you click the cross in front of a step, the step is deleted and returns to the previous step. This is the step recorder of Power Query. When we make a mistake in a certain step and need to go back, we can select any of the above steps to view the results of that step, or delete a new step.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

Next delete other unnecessary columns. Hold down Ctrl to select the column you want to delete, and click "Delete Column" in the [Manage Columns] group under the Home tab.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

To change the new column name to the original column name, you can directly use the first row of fields as the column name. Click "Use first row as title" in the [Conversion] group under the Home tab.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

Since the merged worksheets have multiple titles, filter out the duplicate titles. Click the filter button on the upper right side of the salesperson column and check off "Salesperson".

1Excel case sharing: Use Powerquery to merge multiple sheets with one click

This completes what we want to do. Click "Close and Upload" in the [Close] group under the Home tab.

1Excel case sharing: Use Powerquery to merge multiple sheets with one click

Close and upload means uploading all the queries made in Power Query to each worksheet. If there is only one query, you can use this method.

Close and upload to a pop-up window for everyone to choose whether to upload to the table or create a connection. The created connection can be directly used to generate pivot tables, etc., which will be introduced to you later.

In this way, the content in Power Query will be uploaded directly to the table. In order to facilitate summary, we insert the organized data into the pivot table.

1Excel case sharing: Use Powerquery to merge multiple sheets with one click

This summary query is completed. Let's try adding a worksheet to the data source workbook. The field names inside are consistent with other worksheets. Click Save.

1Excel case sharing: Use Powerquery to merge multiple sheets with one click

#Then click "Refresh All" in the [Connection] group under the Data tab in the summary table.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

The new worksheet will be added.

1Excel case sharing: Use Powerquery to merge multiple sheets with one click

Similarly, when the work table is reduced or the data changes, it can be completed in this way. In this way, you can easily summarize the data in the workbook.

Sometimes we may have a lot of source data, and the response of uploading all the data to the table will be slow. In that case, we can directly use the connection to generate a pivot table for analysis.

What appears in the workbook query window on the right side of the worksheet is the query we have made. Select the query, right-click and select "Load to".

1Excel case sharing: Use Powerquery to merge multiple sheets with one click

If you do not have this workbook query window, you can click "Show Query" in the [Get and Convert] group of the Data tab.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

In the "Load to" window, select "Only create a connection" and click Load.

Excel case sharing: Use Powerquery to merge multiple sheets with one click

The query completed in this way is stored in the workbook in the form of a connection. Then click "PivotTable" in the [Table] group under the Insert tab.

2Excel case sharing: Use Powerquery to merge multiple sheets with one click

Before creating a Pivot Table, you always select the first table or range. We select the second "Use external data source" and click "Select Connection".

2Excel case sharing: Use Powerquery to merge multiple sheets with one click

In the existing connection window, you can see the connection we just created, select it and click to open, and then confirm to insert the pivot table.

2Excel case sharing: Use Powerquery to merge multiple sheets with one click

In this way, you can see the pivot table generated based on this connection, which is the same as the pivot table we just created using the table.

2Excel case sharing: Use Powerquery to merge multiple sheets with one click

On the one hand, this method can avoid excessive EXCEL data causing the file to be too large. On the other hand, if data summary is required, it can also reduce the step of loading into the table.

Related learning recommendations: excel tutorial

The above is the detailed content of Excel case sharing: Use Powerquery to merge multiple sheets with one click. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:itblw.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template