search
HomeTopicsexcelPractical Excel skills sharing: Use Power Query to merge workbooks in folders

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

I previously introduced you to the use of EXCEL’s new function Power Query to summarize the worksheets in the workbook, but the function of Power Query is far more than that. Today I will introduce it to you. More advanced merging techniques: Use Power Query to merge workbooks in folders.

As shown below, there are sales data for four regions in the "Sales" folder on the desktop. The title names in each workbook are consistent, and the order can be different. The value of the city column in each workbook is the name of the workbook, which is convenient for viewing the merge effect later.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Power Query

#The operation is as follows:

Close the files in the folder, create a new workbook, click on the Data tab, [Get and Transform] group "New Query" --- "From File" --- "From Folder".

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Enter the folder path, or browse to select the folder location and click OK.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

This interface lists all the workbooks in the folder, click Edit.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Entered the Power Query editor interface. 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.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

As introduced before, the green font in the "Content" column means that this cell contains a file. Click on a cell to preview its contents. (

Note: When previewing the content in the cell, you should place the mouse on the blank space in the cell, not on the text. Clicking on the text will directly open the file in the cell) Since the file is directly opened from the folder The extracted files are all in binary format, so the workbook in binary format appears in the preview pane below.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Binary as a binary file cannot be displayed in the table, so what we have to do is to change it into table format and then expand the data into the table inside. Delete other unnecessary columns first.

Select the "Content" column, click "Delete Column" - "Delete Other Columns" in the [Manage Columns] group under the Home tab.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

In this way, all other columns except the "Content" column are deleted.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

#So how to convert the binary file into an ordinary table requires the use of Power Query's special programming language-M language. Here I will introduce you to a commonly used function.

Click "Custom Column" in the [General] group under the Add Column option.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

In the Custom Column window, enter =Excel.Workbook([Content],true) in the "Custom Column Formula", where "[ Content]" You can click "Content" in the available column on the right, and then click on the lower right corner to insert (Note: the capitalization of the formula must not be wrong).

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Formula analysis:

Excel.Workbook

Function: Return the records of the worksheet from the Excel workbook.

Parameters: Excel.Workbook(workbook as binary, optional useHeaders as nullable logical, optionaldelayTypes as nullable logical) as table

This function returns a table. The first parameter workbook is in binary format, and the second parameter is the logical value of the optional parameter. true means using the title of the original table as the new table. The title, the default is false, means replacing the title of the original worksheet with the new column name. Don't worry about the third parameter.

Here we still use the original title of the form, so fill in true. This saves the subsequent step of improving the first line of the title.

The new column is added successfully. Preview one of the cells. What is shown below is a table-style workbook. This can be directly extended to the table.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

The "Data" column displays a table in Table format, including the data in the table. Here we only need to extract this column. . Click the expand button in the upper right corner of the custom column, select the expanded column "Data", and uncheck "Use original column name as prefix".

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

The column name becomes "Data". At this time, we preview the data in "Data", and what appears below is the original data in the table. Then extract all the data below.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Similarly click the expand button on the upper right side of the custom column, select expand all columns, and do not check "Use original column name as prefix".

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

In this way, we obtain the data in the worksheet by drilling layer by layer.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Finally delete the "Content" column. Select the "Content" column and right-click to delete it.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

#Finally, just upload this table to the form.

Click "Close and Upload" in the [Close] group under the Home tab.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

#The data will be summarized in the worksheet.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

When you click the filter button in the "City" column, you will see that the data in the four workbooks are all in the table.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

What happens when there is one more workbook in the folder? Try placing a new workbook "Xi'an" in this folder.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Go back to the table where you just made statistics, click [ under the data tab "Refresh All" in the Connection] group.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

The city column has "Xi'an" added, which represents the data of this new workbook was added.

Practical Excel skills sharing: Use Power Query to merge workbooks in folders

Summary: Power Query merges folders. As long as the titles in each worksheet are the same, it can be merged and summarized. This method does not care about the folders. Any number of workbooks can be merged. And any data changes can be updated with one click through all refresh.

Power Query is a powerful tool for EXCEL data analysis. Through simple graphical operations, combined with its own M language and through the operation recorder, it helps us to operate more data in a unified manner and quickly complete data processing and optimization. Moreover, it is faster to get started and easier to operate than VBA, and graphical operation can meet most of our needs. Everyone, hurry up and learn!

Related learning recommendations: excel tutorial

The above is the detailed content of Practical Excel skills sharing: Use Power Query to merge workbooks in folders. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:部落窝教育. If there is any infringement, please contact admin@php.cn delete
一文教会你Excel折叠表格分类汇总功能一文教会你Excel折叠表格分类汇总功能May 12, 2022 am 11:58 AM

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于折叠表格的相关问题,就是分类汇总的功能,这样查看数据会非常的方便,下面一起来看一下,希望对大家有帮助。

实用Excel技巧分享:计算年数差、月数差、周数差实用Excel技巧分享:计算年数差、月数差、周数差Apr 22, 2022 am 09:56 AM

在之前的文章《实用Excel技巧分享:利用 数据透视表 来汇总业绩》中,我们学习了下Excel数据透视表,了解了利用数据透视表来汇总业绩的方法。而今天我们来聊聊怎么计算时间差(年数差、月数差、周数差),希望对大家有所帮助!

实例总结Excel中AGGREGATE函数的八个用法实例总结Excel中AGGREGATE函数的八个用法May 17, 2022 am 11:37 AM

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于AGGREGATE函数的相关内容,该函数用法与SUBTOTAL函数类似,但在功能上比SUBTOTAL函数更加强大,下面一起来看一下,希望对大家有帮助。

Word与Excel联动:表格借用Word进行分栏打印!Word与Excel联动:表格借用Word进行分栏打印!May 07, 2022 am 10:28 AM

在之前的文章《实用Word技巧分享:聊聊你没用过的“行号”功能》中,我们了解了Word中你肯定没用过的"行号”功能。今天继续实用Word技巧分享,看看Excel表格怎么借用Word进行分栏打印,快来收藏使用吧!

实用Excel技巧分享:合并单元格后实现筛选功能实用Excel技巧分享:合并单元格后实现筛选功能May 11, 2022 am 10:22 AM

在之前的文章《实用Excel技巧分享:原来“定位功能”这么有用!》中,我们了解了定位功能的妙用。而今天我们聊聊合并后的单元格如何实现筛选功能,分享一种复制粘贴和方法解决这个问题,另外还会给大家分享一种合并单元格的不错的替代方式。

实例详解利用Excel制作倒计时牌实例详解利用Excel制作倒计时牌May 16, 2022 am 11:53 AM

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于zenmm制作倒计时牌的相关内容,使用Excel中的日期函数结合按指定时间刷新的VBA代码,即可制作出倒计时牌,下面一起来看一下,希望对大家有帮助。

Excel怎么查找总和为某个值的组合Excel怎么查找总和为某个值的组合May 18, 2022 am 11:25 AM

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于如何使用函数寻找总和为某个值的组合的问题,下面一起来看一下,希望对大家有帮助。

图文详解Excel中XLOOKUP函数典型用法整理图文详解Excel中XLOOKUP函数典型用法整理Apr 21, 2022 am 11:46 AM

本篇文章给大家带来了关于Excel的相关知识,其中主要介绍了关于XLOOKUP函数的相关知识,包括了常规查询、逆向查询、返回多列、自动除错以及近似查找等内容,下面一起来看一下,希望对大家有帮助。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft