Xu Hướng 6/2023 # How To Combine Tables With Power Query # Top 7 View | Hoisinhvienqnam.edu.vn

Xu Hướng 6/2023 # How To Combine Tables With Power Query # Top 7 View

Bạn đang xem bài viết How To Combine Tables With Power Query được cập nhật mới nhất trên website Hoisinhvienqnam.edu.vn. Hy vọng những thông tin mà chúng tôi đã chia sẻ là hữu ích với bạn. Nếu nội dung hay, ý nghĩa bạn hãy chia sẻ với bạn bè của mình và luôn theo dõi, ủng hộ chúng tôi để cập nhật những thông tin mới nhất.

Bottom Line: Learn how to combine tables in Excel using Power Query.

Skill Level: Intermediate

Video Tutorial Download the Excel File

If you’d like to download the file that I use in the video, you can do so here:

Here is the file that contains the VBA macro to create Power Query connections to all tables in the workbook.

Combining Tables

If you have tables on several worksheets that contain the same type of data and you are looking to combine them into one master table, Power Query can help you do it quickly and effectively. This is a great alternative to copying and pasting data piece by piece, which can get tedious if there are several tables that you want to merge.

There are just two prerequisites to keep in mind.

Prerequisite #1

All of the sheets or data sets that you are looking to combine must be formatted as Excel Tables, not just data set up in a table format.

To turn a data set into an Excel Table, just select any cell in the set and then choose Format as Table on the Home tab. It’s usually a good idea to name the table after you’ve created/inserted it.

If you are relatively new to Excel Tables, check out my Beginner’s Guide to Excel Tables. Here are some useful Tips & Shortcuts for Inserting Excel Tables, and this post will give you some Best Practices for Naming Excel Tables.

Prerequisite #2

The tables you are working with must contain the same column headings, though they do not have to be in the same order. If you are working with columns that have similar data, but your headings are not the same, Power Query will put them into different columns when it combines them.

There are ways around this, which I will cover in a future post.

The Setup Work in Power Query

Now you can create queries in Power Query. First we will create connection queries for each table. Then we will combine those queries with an Append query to combine or stack the data.

1. Create Connection Queries to the Tables

To combine, or append, your tables together, you need to create a connection to each of them in Power Query.

This brings up a preview of your data. To create a connection:

Select Close & Load To…

That brings up the Import Data window. From here, select Only Create Connection.

You can see the connection you’ve just created in the Queries & Connections pane. If ever you don’t see the Queries & Connections pane, you can open it by selecting that button on the Data tab in the ribbon.

This process of creating connections must be repeated for every table that you want to append. Again, you only need to do this work one time for the initial setup. However, here are a few tips to speed up the process.

Use the Table Connections Macro

Since creating and connecting lots of tables can be time-consuming, I’ve created a macro that automates it. The macro loops through all tables in the workbook and creates connection only queries for any table that do not have queries yet.

I will write a post in the future that explains the macro. However, you can download the file that contains the VBA macro code here.

The macros runs on the Active Workbook. You can add the macro to your Personal Macro Workbook and add a macro button to the Ribbon or Quick Access Toolbar to run it on any open workbook.

Close & Load Settings

If you’d rather not use a macro, you can also shorten the process by changing the setting of the Close & Load split-button. The default for the top half of that button will load the output table to a new sheet, but you can adjust the settings so that it only creates a connection instead. To change the setting:

Go to the File menu.

Select Options and Settings.

Choose Query Options.

That will bring up the Query Options window, where you can select Specify custom default load settings.

Deselect the Load to worksheet option.

Hit OK.

Just remember to change this setting back once you’ve finished connecting all of your tables.

2. Combining Connected Tables with Append

Once all of your tables are connected, it’s a piece of cake to consolidate them:

This brings up the Append window, where we can select Three or more tables. This allows us to move any or all of the tables that we’ve connected from our Available tables (on the left) to the list of Tables to append (on the right).

Once you hit OK, you will be taken back to the Power Query editor, where you can see a preview of the combined tables. You can make adjustments and transformations to the data before closing the editor and loading the data to a new worksheet.

Updating & Refreshing the Data

This means we have fully automated this process. You do NOT have repeat the steps above every time your data changes or you get new rows in your tables.

Adding New Tables

If you ever want to add new tables to the query (or exlcude existing ones) you can reopen the Append window by:

Opening the Query Settings pane if it’s not already visible (View tab, then Query Settings).

This opens the Append window, where you can add or delete tables.

The new columns will still need to have the same column header name on each sheet. If any of the tables are missing columns, then Power Query will fill the rows for that table with blank (null) values in the append query and output table.

Other Power Query Posts

If you’re just getting started with Power Query, check out my overview post here: Power Query Overview: An Introduction to Excel’s Most Powerful Data Tool.

Then get Power Query up and running with this tutorial: The Complete Guide to Installing Power Query.

Free Training Webinar on the Power Tools

Right now I’m running a free training webinar on all of the Power Tools in Excel. This includes Power Query, Power Pivot, Power BI, pivot tables, macros & VBA, and more.

It’s called The Modern Excel Blueprint. During the webinar I explain what these tools are and how they can fit into your workflow.

You will also learn how to become the Excel Hero of your organization, that go-to gal or guy that everyone relies on for Excel help and fun projects.

Join Two Or More Tables In Excel With Power Query

In this tutorial, we will look at how you can join tables in Excel based on one or more common columns by using Power Query and Merge Tables Wizard.

Combining data from multiple tables is one of the most daunting tasks in Excel. If you decide to do it manually, you may spend hours only to find out that you’ve messed up important information. If you are an experienced Excel pro, then you can possibly rely on VLOOKUP and INDEX MATCH formulas. A macro, you believe, could do the job in no time, if only you knew how. The good news for all Excel users – Power Query or Merge Tables Wizard can be your time-saver. The choice is yours.

How to join tables with Excel Power Query

In simple terms, Power Query (also known as Get & Transform in Excel 2023 and Excel 2023) is a tool to combine, clean and transform data from multiple sources into the format you need such as a table, pivot table or pivot chart.

Among other things, Power Query can join 2 tables into 1 or combine data from multiple tables by matching data in columns, which is the focus of this tutorial.

For the results to meet your expectations, please keep in mind the following things:

Power Query is a built-in feature in Excel 2023 and Excel 2023, but it can also be downloaded in Excel 2010 and Excel 2013 and used as an add-in. In earlier versions, some windows may look different from the images in this tutorial that were captured in Excel 2023.

For the tables to be combined correctly, they should have at least one common column (also referred to as a common id or key column or unique identifier). Also, the common columns should contain only unique values, with no repeats.

The source tables can be located on the same sheet or in different worksheets.

Unlike formulas, Power Query does not pull data from one table to another. It creates a new table that combines data from the original tables.

The resulting table does not update automatically. You should explicitly tell Excel to do this. Please see how to refresh a merged table.

Source data

As an example, let’s join 3 tables based on the common columns Order ID and Seller. Please note that our tables have different numbers of rows, and although table 1 has duplicates in the Seller column, table 3 contains only unique entries.

Our task is to map the data in table 1 with the relevant records from the other two tables, and combine all the data into a new table like this:

Table 1 is named Orders

Table 2 is named Products

Table 3 is named Commissions

Create Power Query connections

Not to clutter your workbook with copies of your original tables, we are going to convert them into connections, do the merge within the Power Query Editor, and then load only the resulting table.

To save a table as a connection in Power Query, here’s what you do:

Select your first table (Orders) or any cell in that table.

This will create a connection with the name of your table/range and display that connection in the Queries & Connections pane that appears on the right-hand side of your workbook.

Repeat the above steps for all other tables you want to merge (two more tables, Products and Commissions, in our case).

When finished, you will see all the connections on the pane:

Merge two connections into one table

With the connections in place, let’s see how you can join two tables into one:

In the Merge dialog box, do the following:

Select your 1st table (Orders) from the first drop-down.

Select your 2nd table (Products) from the second drop-down.

In the Join Kind drop-down list, leave the default option: Left Outer (all from first, matching from second).

Upon completion of the above steps, the Power Query Editor will show your first table (Orders) with one additional column named like your second table (Products) added to the end. This additional column does not have any values yet, just the word “Table” in all the cells. But don’t feel discouraged, you did everything right, and we are going to fix that in a moment!

Select the columns to add from the second table

At this point, you have a table resembling the one in the screenshot below. To complete the merging process, perform the following steps within the Power Query Editor:

In the box that opens, do this:

Keep the Expand radio button selected.

Unselect all columns, and then select only the column(s) you want to copy from the second table. In this example, we select only the Product column because our first table already has Seller and Order ID.

Uncheck the Use original column name as prefix box (unless you want the column name to be prefixed with the table name from which this column is taken).

As the result, you will get a new table that contains every record from your first table and the additional column(s) from the second table:

If you need to merge only two tables, you may consider the work almost done and go load the resulting table in Excel.

Merge more tables (optional)

In case you have three or more tables to join, there is some more work for you to do. I will outline the steps briefly here, because you have already done all this when joining the first two tables:

Save the table you’ve got in the previous step (shown in the screenshot above) as a connection:

The screenshot below shows my settings:

In this example, we add only the Commission column:

As the result, you get a merged table that consists of the first table, plus the additional columns copied from the other two tables.

Import the merged table to Excel

With the resulting table in the Power Query Editor, there is just one thing left for you to do – load it in your Excel workbook. And it is the easiest part!

In the Import Data dialog box, select Table and New Worksheet options.

A new table combining the data from two or more sources appears in a new worksheet. Congratulations, you did it!

As a finishing touch, you may want to apply the right number format to some columns and maybe change the default table style to your favorite one. After these improvements, my combined table looks very nice:

In the previous example, we were combining tables by matching data in one key column. But there is nothing that would prevent you from selecting two or more column pairs. Here’s how:

After that, perform exactly the same steps as described above, and your tables will be merged by matching values in all the key columns.

Merge Tables Wizard – quick way to join 2 tables in Excel

Now that you are familiar with the inbuilt tool, let me show you our approach to merging tables in Excel.

In this example, we will be combining the same tables that we joined with Power Query a moment ago. I have just added a few more rows to the second table to show you more capabilities of our add-in:

With the Merge Tables Wizard installed in your Excel, here’s what you need to do:

Please notice the Case-sensitive matching box at the top. Select it if you want to treat uppercase and lowercase text in the key columns as different characters. For this example, we don’t need that, so we leave the box unselected.

We select the Seller column because we have more rows in the second table and we want the new seller names to appear in the existing Seller column:

This step is very important because it determines how your tables will be merged. In this example, we go with the default options shown in the screenshot below. But I’d like to draw your attention to the following 2 boxes that can prevent overwriting your existing data in case you’ve chosen to update some columns:

Empty cells only

Only if cells in the lookup table contain data

With the default options, the wizard highlights the newly added rows and adds the Status column. If you don’t want any of that, clear the corresponding boxes in the last step.

To join three and more tables, simply repeat the above steps. Just remember to select the result of a previous merge as your main table.

This example has shown just one scenario that our wizard can handle, but there is much more to it! If you are curious to know other use cases, please check out these examples.

Also, you can download a a trial version of Ultimate Suite for Excel that includes Merge Tables Wizard as well as 60+ other useful tools.

In case you are looking to join tables in some other way, you may find the following resources useful.

Other ways to combine data in Excel:

Merge tables by column headers – join two or more tables based on column names. You can choose to combine all the columns or only the ones you select.

Combine multiple worksheets into one – copy multiple sheets into one summary worksheet. Of course, it’s not manual copy/pasting! You only indicate which worksheets to merge, and our Copy Sheets tool does the rest.

Compare two Excel files – how to compare two tables (worksheets) for differences and merge them into a single sheet.

How To Combine Shapes To Create A Custom Shape

Sometimes you need to combine two or more shapes for creating a fancy diagram or other visual elements. Sure, you can add these shapes to the slide and then group them. But in some situations, such as frequent use of the same groups of shapes, it will be more useful to create your own shape.

There are two ways to create a custom shape:

Make one shape from some existing shapes,

Modify an existing shape.

To make a shape from some existing shapes, do the following:

    1.    Add shapes to the slide, for example:

When you select all shapes, PowerPoint shows the Drawing Tools toolbar:

    2.    Under Drawing Tools, on the Format tab, in the Insert Shapes group, when you choose the Merge Shapes dropdown list, you will find the following operations:

Union shapes:

Combines all overlapping and non-overlapping areas of shapes

Subtracts nothing

Retains formatting of the first selected shape

Combine shapes:

Combines non-overlapping areas of shapes

Subtracts overlapping areas of shapes

If selected shapes do not overlap, acts like a group with no option to ungroup

Retains formatting of the first selected shape

Fragment shapes:

Creates new shapes from the overlapping area of shapes

Creates new shapes from in-between empty areas

Retains as shapes any areas that do not overlap

Subtracts nothing

Retains formatting of the first selected shape

Intersect shapes:

Creates shape from the overlapping area from all shapes

If any shapes do not overlap, nothing will be created

Removes non-overlapping areas of shapes

Retains formatting of the first selected shape

Subtract shapes:

Retains the first selected shape

Subtracts overlapping areas of other shapes from the first selected shape

Removes all non-overlapping areas

Retains formatting of the first selected shape

See also this tip in French: Comment combiner des formes pour créer une forme personnalisée.

The Complete Guide To Installing Power Query

Power Query is an amazing data tool for Excel! It is built by Microsoft to help you import, transform, and automate your data processes. Checkout my overview of Power Query to learn more about it.

Here is a quick list of compatible versions:

“Free” add-in for Excel 2010 and 2013 for Windows.

Power Query is not yet available for the Mac versions of Excel.

Video Guide to Installing Power Query What Version Do I Need?

The download page for Power Query lists which version of Excel are compatible with Power Query.

The following Office versions for Windows are supported:

Microsoft Office 2023 – All Versions

Microsoft Office 2013 – All Versions

Microsoft Office 2010 Professional Plus with Software Assurance

Both 32-bit and 64-bit are supported. Power Query is not compatible with any Mac versions of Excel yet.

Unfortunately, if you don’t have these versions you will need to upgrade to use Power Query. To me, Power Query is worth the upgrade to Office 365 alone, and there are a lot of other cool new features too.

How Do I Check My Version of Excel? Excel 2010

Here’s how to determine your version and 32 or 64 bit in Excel 2010:

The Excel version will be listed under the Product Activated section.

The bit version (32-bit or 64-bit) will be listed under the About Microsoft Excel section.

Excel 2013

Here’s how to determine your version and 32 or 64 bit in Excel 2013:

The Excel version will be listed under the Subscription Product section.

Excel 2023

Power Query is included with Excel 2023 (Office 365). It has been renamed and is now on the Data tab of the Ribbon in the Get & Transform section.

Power Query is available with all levels of Office 365 subscriptions. Here is an article that explains the features available for each subscription level.

It’s important to note that there are some differences in Power Query for different builds of Excel 2023.

If you are on the MSI (Windows Installer) version then you will not get frequent updates to Power Query. Your ribbon might look different from mine, and you won’t have all the latest features.

If you are on the ProPlus version of Office 365 then you might be on the Deferred Channel. The name of the Deferred Channel has been changed to Semi-Annual Channel as of September 2023. This means you get updates every six months instead of every month.

Here is an article about the different channels for Office 365 ProPlus.

Here is an article on how to switch channels.

All the versions and channels make this very confusing, to say the least. Hopefully this guide helps you figure out how to get Power Query for Excel 2023.

Checkout my article on an Overview of Power Query to learn more about this awesome tool!

Excel 2010 & 2013

For Excel 2010 and 2013 you will need to download the Power Query add-in and install it.

The installation steps are about the same in Excel 2010 and 2013.

Close (exit) Excel completely.

My Power Query Tab Disappeared

If your Power Query tab ever goes missing, you can usually re-enable the add-in by going to the COM Add-ins menu.

There are a few ways to get to the COM Add-ins menu.

File menu.

Select COM Add-ins from the Manage drop-down.

There is also a button on the Developer tab that will take you directly to this window.

Power Query is my favorite tool for working with data in Excel. If you are not familiar with what Power Query can do, checkout my article on an Overview of Power Query to learn more.

Cập nhật thông tin chi tiết về How To Combine Tables With Power Query trên website Hoisinhvienqnam.edu.vn. Hy vọng nội dung bài viết sẽ đáp ứng được nhu cầu của bạn, chúng tôi sẽ thường xuyên cập nhật mới nội dung để bạn nhận được thông tin nhanh chóng và chính xác nhất. Chúc bạn một ngày tốt lành!