Xu Hướng 4/2023 # Power Query Overview: An Introduction To Excel’s Most Powerful Data Tool # Top 4 View | Hoisinhvienqnam.edu.vn

Xu Hướng 4/2023 # Power Query Overview: An Introduction To Excel’s Most Powerful Data Tool # Top 4 View

Bạn đang xem bài viết Power Query Overview: An Introduction To Excel’s Most Powerful Data Tool đượ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 this awesome feature of Excel and Power BI called Power Query will help you automate the process of importing, transforming, and cleansing your data to save a TON of time with your job.

Skill level: Beginner

Video Tutorial

Download the Sample Files

The CSV files I use in the video are available for download below. You will need to extract the files out of the zip file.

Introduction to Power Query

In this tutorial I provide an introductory explanation of Power Query.  You will learn why this is my new favorite Excel tool for working with data, and how it can help automate processes and save you time!

The Power Query Data Machine

I was watching a TV show on how things are made, and they were explaining how a depositor machine worked in a pastry factory.

The basics of a depositor machine are:

You add ingredients to it.

Change some settings.

And it magically creates pastries (cookies, donuts, biscuits) that are ready for baking.

Once the dials are set, the process can be repeated over-and-over again to make perfect pastries every time.  Getting hungry…? 🙂

Power Query works in a very similar way!

You add your data sources (Excel tables, CSV files, database tables, webpages, etc.)

Press buttons in the Power Query Editor window to transform your data.

Output that data to your worksheet or data model (PowerPivot) that is ready for pivot tables or reporting.

If you have used macros to transform your data, you can think of this as a much easier alternative to VBA that does NOT require coding.

Common Data Tasks Made Easy

Do you work with data that has been exported from a system of record?  This could be a general ledger, accounting, ERP, CRM, chúng tôi or any reporting system that contains data.

If so, you probably spend a lot of time transforming or re-shaping your data to create additional reports, pivot tables, or charts.

These data transformations could include tasks like:

Remove columns, rows, blanks

Convert data types – text, numbers, dates

Split or merge columns

Sort & filter columns

Add calculated columns

Aggregate or summarize data

Find & replace text

Unpivot data to use for pivot tables

Do any of these tasks sound familiar?  If so, then they probably also sound boring, repetitive, and time consuming. 🙂  Believe me, I’ve spent the better part of my career doing these tasks and trying to figure out faster ways to get them done.

Fortunately, Power Query has buttons that automate all these tasks!

Overview of the Power Query Ribbon

Starting in Excel 2016 for Windows, Power Query has been fully integrated into Excel.  It is now on the Data tab of the Ribbon in the Get & Transform group.

In Excel 2010 and 2013 for Windows, Power Query is a free add-in.  Once installed, the Power Query tab will be visible in the Excel Ribbon.

You use the buttons in the Data or Power Query tab to get your source data.  Again, your data could be stored in Excel files, csv files, Access, SQL server database, SharePoint, chúng tôi Dynamics CRM, Facebook, Wikipedia, websites, and more.

Once you have specified where your data is coming from, you then use the Power Query Editor window to make transformations to the data.

The buttons in the Power Query Editor Window allow you to transform your data.

Think about some of those tasks you do repeatedly as you browse the buttons in the image above.  Each time you press a button your actions (steps) are recorded, and you can quickly re-apply the steps when you receive new data by refreshing the query.

You can also modify existing queries and refresh your output tables with the changes or updated data.

Data Transformation Examples

Here are a few examples of what Power Query can do with your data.

Unpivot Data for Pivot Tables

My favorite feature of Power Query is it’s ability to Unpivot data.  This is a technique used to get your data ready for the source of a pivot table.  This is also referred to as normalizing your data to get it in a tabular format.

The data might start out looking something like the following.

And you want the end result to look like this.

Here is an article and video on exactly How to Unpivot Your Data with Power Query.

Checkout my article on how to structure your source data for a pivot table if you are unfamiliar with why your data needs to look like this for a pivot table.

Append (Combine) Tables with Power Query

The Append feature of Power Query allows you to combine multiple tables (stack them vertically) to create one large table.  It can do this with multiple tables in one file, or it can pull in data from a bunch of different files/sources.

Let’s say you have a folder that contains CSV or Excel files with report data for each month.  Throw all those files in the Power Query machine, and it will spit out one nice table that you can then use to create pivot tables and charts.

If the data in those reports also needs to be transformed (remove rows, split columns, unpivot, etc.), then Power Query can handle that in the same process.

Once it is setup, all you have to do is hit the refresh button every month when a new file is added to the folder and the rows will be added to your output table.

How awesome is that! 🙂

Merge Tables – A VLOOKUP Alternative

Power Query has the ability to merge or join tables.  This can be used as an alternative to VLOOKUP or INDEX/MATCH formulas.

Let’s say you have this data table of sales records, and you are using a VLOOKUP to bring in information about the product based on the name of the product sold.  Your product group information is located in another table on a different sheet or workbook.

Using VLOOKUP formulas is great, but it can often mean adding thousands of formulas to your workbook.  Which increases the file size and calculation time.

Create Custom Functions

However, Power Query can be programmed to create custom functions.  This gives you seemingly unlimited potential to transform your data in just about any way possible.

It is based on the M language, and most of the functions are very similar to writing a formula in Excel.  This also makes it more user friendly and easier to learn the code.

This new language and set of functions means there is a lot to learn, but I consider that the fun and challenging part.  Plus, employers of the future will definitely be looking for employees with Power Query skills.

Power Query Records Your Steps & Automates Processes

Power Query not only makes all these tasks easier, but it also records your steps so you do NOT have to do them over-and-over again.  It will save you a lot of time if you are preparing the same data every day, week, or month.

It also does a pretty good job of handling errors.  If the structure of your source data changes, Power Query will tell you what step it broke at and allow you to fix it.  This makes maintenance easy and you don’t have to completely redo your process when something changes.

You can use Power Query to get your data ready for use in pivot tables, charts, and dashboard reports.  This is a critical step in the process of summarizing and analyzing data.

The Power Query Machine & Power BI

Well, it can’t exactly make cookies, but Power Query is a pretty awesome tool!  It will save you a ton of time when transforming your data.

Power Query is just one piece of the suite of Power BI (Business Intelligence) products from Microsoft.

If we go back to the analogy of baking cookies in a factory, you can think of Power Query as the first step in the assembly line.  Once the cookies are formed, we then need to bake them (Pivot Tables, PowerPivot) and then package them for presentation (Power View, Power Map, Charts, Dashboards, etc.)

How Do I Get Power Query?

The other nice part is that Power Query is now built into Excel starting with Excel 2016 for Windows.  If you are on Excel 2010 or 2013 then Power Query is a free add-in.

I have a dedicated page that will help you determine if you have the right version of Excel to get Power Query.  It also provides complete installation instructions and the download link.

Complete Guide to Installing Power Query

To give you an idea of the importance of this tool, Power Query was fully integrated into Excel in Excel 2016 for Windows, and is on the Data tab of the Ribbon.  

It is also known as Get & Transform, although the term Power Query is most common.

Additional Resources

This article has provided an overview of the basics of Power Query that should help you understand some of the major features.  Power Query has a ton of features and there is definitely a lot to learn.

I will be sharing more how-to articles and videos in the coming weeks.  Here are a few resources that will help you get started.

How to Unpivot Your Data with Power Query + Video Tutorial

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.

What Do You Think?

If not, do you think it would be useful for you?  Are you doing any of the tasks I mentioned manually right now?

I will be creating more how-to articles and videos on Power Query in the future, so I’m interested to know what you want to learn.

Thank you! 🙂

Introduction To Power Pivot – Excel Exposure

Introduction to Power Pivot

Here’s a helpful guest lesson about an incredibly useful Excel add-in called Power Pivot. Thanks to Nick Williams from Acuity Training for creating this helpful post!!!

Power Pivot is an Excel add-in which can used to perform powerful data analysis and create sophisticated data models. It can handle large volumes of data (millions of rows) from various sources and all of this within a single Excel file.

Power Pivot is basically a SQL Server Analysis Services engine made available using an in-memory process that runs directly within Excel. It is commonly referred to as an Internal Data Model. The most effective way to interact with the Internal Data Model is to use the Power Pivot Ribbon interface.

Once the Power Pivot add-in is installed and available, you can create a Data Model, which is a collection of tables with relationships. Any data you import into Excel or already have in Excel, once added to the data model is available in the Power Pivot window. The Power Pivot Ribbon gives you additional functions over and above the standard Excel Data tab.

The Power Pivot add-in is available in Excel 2010, and is native in Excel 2013 and 2016. However, only the following versions of Excel 2016 support the ‘Power Query’ functionality:

Excel 2016 – Office 365 ProPlus

Excel 2016 – Office 365 E3

Excel 2016 – Office 365 E4 andE5

To give you a feel for where Power Pivot fits in when using Excel for data analysis or visualization, let’s first have a quick look at how Power Pivot fits into the overall Business Intelligence process and how it works with the other BI tools in Excel.

Power Pivot acts as a data model, this means that the first step is to import some data. Unless it is already in your Excel sheet you will need a tool or connector to connect to different types of data sources and fetch your data. This can be a complex subject depending on your data source and is beyond the scope of this article.

After fetching the data, you will probably need to do some cleaning and transformation on it. Both these functions in Excel are carried out by another add-in called Power Query (in Excel 2010 and 2013) / Get & Transform (in Excel 2013).

The final step is creating the Power Pivot data model. This is where we create the relationships between different data tables.

You can create simple measures or Key Performance Indicators (KPIs) in Power Pivot.

Finally one you have all of the required metrics calculated, you can summarize the information in your Power Pivot data model using Pivot Tables and / or Pivot Charts. The combination of multiple Pivot Tables / Pivot Charts with slicers can be used to create a Dashboard

Lets look at how you launch Power Pivot.

To install the Power Pivot add-in:

The green Manage icon launches the Power Pivot window. Calculated Fields and KPIs can be used to create any summarizing calculations. Add to Data Model allows you to add the data table present in the Excel into Power Pivot. Update All allows you to update all the data connections established with the data model. Settings helps to control other parameters associated with Power Pivot.

Example 1: Adding Data to the Data Model

The first step is to add some data into the data model. Data sources fall into two broad categories. First, it comes via an import from an external data source. Second it is present in the Excel tables in the current workbook.

For now, let us take an example which shows how to work with Excel tables in the current Excel workbook to Power Pivot. Use the below Excel workbook to follow along:

Once you have saved the file and opened that, you’ll notice that there are two tabs. One, data tab and the other mapping tab.

The data tab has the sales info as shown in the screen shot below. The data tab contains detailed data showing sales by country, by product type, by quarter, by sales channel etc. The mapping tab contains that data sub-totaled by quarter, also seen below.

Data Tab:

Mapping Tab:

The mapping tab has a table showing a method of “mapping” or a lookup table that allows you to change from the quarter notation to the year and/or the quarter. This can also be derived using formula in Power Pivot as well!

First, let’s see how we can add the two tables into the data model. Make sure you have selected the range of the Data table then select the Add to data model button from the Power Pivot Tab:

You’ll notice a new pop-up window opens. It is the Power Pivot window, it has several options to edit, modify and update the data model

Go back to the Excel file and Repeat the steps 4 and 5 with the data in the Mapping tab to add that to the data model.

Please note that for each data added onto the Data Model, a new tab is created in the Power Pivot tab

Creating Relationships

Now that we have two datasets added to the data model. Let’s look at how we can create a relationship between the two.

The common field between the two datasets will be used to create the relationship between them

In this example, Quarter from the Data table is the same as QuarterCode from the Mapping table

This opens a pop-up where you’ll need to select the main table, the lookup table and the corresponding columns

In the current example, the Data table is our main table and the common column is The Mapping table is our Lookup Table and the Related Lookup Column is QuarterCode. Hence the following selections needs to be made in the pop-up

It shows the relationship created, as shown below

You can create a relationship in Diagram View once you get more comfortable with this process.

Now we’ve created a very simple data model let’s look at creating some calculated columns. For more on

Calculated Columns in Power Pivot

In this section, you’ll learn how to create calculated columns in Power Pivot.

First make sure that you are in the Mapping tab of the Power Pivot window

Now, let’s explore how we can derive the year and quarter using just the Quartercode column in the Mapping tab to keep this example very simple.

In the default view, you can see there is a column as “Add Column” as the Header of a column which doesn’t contain any data.

Almost all of the formulas in Power Pivot are the same as they are in Excel. In this example, first we take the first four characters from the QuarterCode using the LEFT function and then use the VALUE function to convert the string of characters into a number. See this video for more details on working with text functions.

Next we add another column called “Quarter Derived” and use the following formula


Similar to the formula in the “Year Derived” column, this formula takes the last digit of the string in the QuarterCode column and converts it into a number.

How To Install Power Query

Power query is a great tool built by Microsoft that will help you work with data in Excel. This tool is great for connecting to various external data sources, querying and transforming data, or cleaning and parsing data.

Web pages, Facebook

Excel, CSV, XML, Text or Hadoop (HDFS) Files

A Folder

Various databases like MS Access, SQL Server, MySQL, Microsoft Azure SQL, Oracle, IBM DB2, PostgreSQL, Sybase, Teradata, OData etc…

This is available as an add-in for excel 2010 professional plus or 2013 and comes already built in for Excel 2016.

You can download Excel Power Query here from Microsoft.

Unfortunately, if you’re not running Excel 2010 professional plus or 2013, then you will need to upgrade to Excel 2016 in order to use this feature as it’s not available for previous versions of Excel. Mac user are also out of luck.

There are both a 32-bit and 64-bit versions and which one you choose will depend on the version of Excel which you have installed.

Excel 2010

To check what version you have:

Go to the “File” tab.

Go to the “Help” section.

Here you will see the product version, if it says professional plus 2010, then you’re in luck.

Here you will either see 32-bit or 64-bit. Take note and download the correct Power Query add-in version accordingly.

Excel 2013

To check what version you have:

Go to the “File” tab.

Go to the “Account” section.

Here you will see the product version.

In the screen that pops up, at the top you will either see 32-bit or 64-bit. Take note and download the correct Power Query add-in version accordingly.

Excel 2016

Power query comes pre-installed in Excel 2016 but has been renamed to “Get & Transform” and is under the Data tab in the ribbon. If you have Excel 2016, then you don’t need to do anything to use it.

Download The Add-In

Go to the Microsoft website:

Select your preferred language.

Select The Correct Version

Select either the 32-bit or 64-bit version depending on your version of Excel.

Run The Setup Wizard

Follow The Setup

Follow the steps in the Setup Wizard.

Power Query Is Now Ready To Use

Now the next time you open up Excel, Power Query will be available to use under its own tab.

Tạo Các Công Thức Power Query Trong Excel

Tạo một công thức đơn giản

Để xem ví dụ về công thức đơn giản, chúng ta hãy chuyển đổi một giá trị văn bản thành kiểu chữ thích hợp bằng cách dùng công thức Text.Proper() .

Trong thanh công thức Trình soạn thảo Truy vấn, hãy nhập = Text.Proper(“text value”), và nhấn Enter hoặc chọn biểu tượng Enter.

Power Query cho bạn thấy kết quả trong ngăn kết quả công thức.

Để xem kết quả trong trang tính Excel, hãy chọn Đóng & Tải.

Kết quả sẽ trông như thế này trong một trang tính:

Bạn cũng có thể tạo công thức truy vấn nâng cao trong Trình soạn thảo Truy vấn.

Tạo công thức nâng cao

Để xem ví dụ về công thức nâng cao, chúng ta hãy chuyển đổi văn bản trong một cột thành kiểu chữ thích hợp bằng cách kết hợp nhiều công thức. Bạn có thể sử dụng Ngôn ngữ Công thức Power Query để kết hợp nhiều công thức thành các bước truy vấn có kết quả tập dữ liệu. Có thể nhập kết quả vào một trang tính Excel.

Chẳng hạn, giả sử bạn có một bảng Excel chứa các tên sản phẩm mà bạn muốn chuyển thành kiểu chữ thích hợp.

Bảng ban đầu trông như thế này:

Và bạn muốn bảng kết quả trông giống như thế này:

Chúng ta hãy xem qua các bước công thức truy vấn để thay đổi bảng ban đầu sao cho các giá trị trong cột Tên Sản phẩm có kiểu chữ thích hợp.

Ví dụ về truy vấn nâng cao bằng Trình soạn thảo Nâng cao

Tạo một chuỗi các bước công thức truy vấn bắt đầu bằng câu lệnh let. Vui lòng lưu ý rằng Ngôn ngữ Công thức Power Query có phân biệt chữ hoa, chữ thường.

Mỗi bước công thức truy vấn xây dựng trên bước trước đó bằng cách tham chiếu đến một bước theo tên.

Tạo đầu ra cho công thức truy vấn bằng câu lệnh in. Thông thường, bước truy vấn sau cùng được dùng làm kết quả tập dữ liệu cuối cùng.

Bước 1 – Mở Trình soạn thảo Nâng cao

Trong Trình soạn thảo Truy vấn, hãy chọn Trình soạn thảo Nâng cao.

Bạn sẽ thấy Trình soạn thảo Nâng cao.

Bước 2 – Xác định nguồn ban đầu

Trong Trình soạn thảo Nâng cao:

Dùng câu lệnh let gán Source = công thức Excel.CurrentWorkbook(). Thao tác này sẽ sử dụng bảng Excel làm nguồn dữ liệu. Để biết thêm thông tin về công thức Excel.CurrentWorkbook(), hãy xem Excel.CurrentWorkbook.

Gán Source cho kết quả in.

letSource = Excel.CurrentWorkbook(){[Name="Orders"]}[Content] inSource

Truy vấn nâng cao của bạn sẽ trông giống như thế này trong Trình soạn thảo Nâng cao.

Để xem kết quả trong một trang tính:

Bấm Xong.

Trong ribbon Trình soạn thảo Truy vấn, bấm Đóng & Tải.

Kết quả sẽ trông như thế này trong một trang tính:

Bước 3 – Tăng cấp hàng đầu tiên thành tiêu đề

Để chuyển đổi các giá trị trong cột Tên Sản phẩm thành kiểu chữ thích hợp, trước tiên bạn cần tăng cấp hàng đầu tiên thành tiêu đề cột. Bạn thực hiện điều này trong Trình soạn thảo Nâng cao:

Thêm #”First Row as Header” = công thức Table.PromoteHeaders() vào các bước công thức truy vấn của bạn và tham chiếu đến Source là nguồn dữ liệu. Để biết thêm thông tin về công thức Table.PromoteHeaders(), hãy xem Table.PromoteHeaders.

Gán #”First Row as Header” cho kết quả in.

let Source = Excel.CurrentWorkbook(){[Name="Orders"]}[Content], #"First Row as Header" = Table.PromoteHeaders(Source) in #"First Row as Header"

Kết quả sẽ trông như thế này trong một trang tính:

Bước 4 – Thay đổi mỗi giá trị trong một cột thành kiểu chữ thích hợp

Để chuyển đổi mỗi giá trị trong cột Tên Sản phẩm thành kiểu chữ thích hợp, bạn dùng Table.TransformColumns() và tham chiếu đến bước công thức truy vấn “First Row as Header”. Bạn thực hiện điều này trong Trình soạn thảo Nâng cao:

Thêm #”Capitalized Each Word” = công thức Table.TransformColumns() vào các bước công thức truy vấn của bạn và tham chiếu đến #”First Row as Header” là nguồn dữ liệu. Để biết thêm thông tin về công thức Table.TransformColumns(), hãy xem Table.TransformColumns.

Gán #”Capitalized Each Word” cho kết quả in.

let Source = Excel.CurrentWorkbook(){[Name="Orders"]}[Content], #"First Row as Header" = Table.PromoteHeaders(Source),#"Capitalized Each Word" = Table.TransformColumns(#"First Row as Header",{{"ProductName", Text.Proper}}) in#"Capitalized Each Word"

Kết quả cuối cùng sẽ thay đổi mỗi giá trị trong cột Tên Sản phẩm thành kiểu chữ thích hợp và trông giống như thế này trong trang tính:

Với Ngôn ngữ Công thức Power Query bạn có thể tạo các truy vấn dữ liệu từ đơn giản đến nâng cao để khám phá, kết hợp và tinh chỉnh dữ liệu. Để tìm hiểu thêm về Power Query, hãy xem Trợ giúp Microsoft Power Query cho Excel.

Cập nhật thông tin chi tiết về Power Query Overview: An Introduction To Excel’s Most Powerful Data Tool 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!