Understanding Excel Power Query - Course Material
Understanding Excel Power Query - Course Material
In the modern world of data management and analysis, the need for efficient, repeatable,
and scalable data transformation has never been greater. Microsoft Excel, a cornerstone of
data handling for millions of users worldwide, evolved to meet this demand with the
introduction of Power Query—a robust tool designed to simplify and automate the
Extract, Transform, Load (ETL) process.
Power Query first appeared as an external add-in for Excel 2010 and 2013, requiring users
to download and install it separately. Recognizing its utility and widespread demand,
Microsoft integrated Power Query as a built-in feature in Excel 2016, placing it under the
"Get & Transform" section of the Data tab. Since then, it has become an essential part of
Excel’s data toolkit.
With the rise of Office 365 and Microsoft 365 subscriptions, Power Query continues to
receive regular updates, introducing new features and improvements based on user
feedback. These updates ensure that users always have access to the latest capabilities for
managing complex data tasks.
At the heart of Power Query lies its ability to streamline the ETL process:
1. Extract: Pull data from multiple and diverse sources—Excel workbooks, CSV files,
databases, web pages, SharePoint folders, cloud services like Salesforce, and many
more.
2. Transform: Clean and reshape data to fit analytical needs. This includes removing
duplicates, filtering rows, changing data types, splitting columns, removing blanks,
and pivoting or unpivoting data.
3. Load: Output the refined data into Excel worksheets or data models, ready for
reporting, pivot tables, dashboards, and further analysis.
This process, once automated, requires no repetition. After setting up a Power Query
solution once, users only need to refresh the data to incorporate new entries or updates—
saving hours of manual work and reducing the risk of human error.
A Practical Scenario
Consider the case of a high school administrator responsible for compiling student
performance reports across different subjects like Mathematics, Chemistry, and Physics.
Each month or quarter, teachers submit Excel files with student grades. Traditionally, this
process involves manually opening each file, copying data into a master sheet, and then
preparing reports from there.
With Power Query, the process becomes seamless. The administrator can connect to a
folder where teachers drop their files, configure Power Query to combine all these datasets,
apply necessary transformations (such as removing empty rows, renaming columns, or
filtering by subject), and load the cleaned data into a consolidated report. From that point
forward, all it takes is one click to refresh the data—and the entire report updates
instantly.
Power Query is a powerful tool for working with data in Excel. If you’re using Excel 2016
or later, you already have Power Query built into Excel under the Data tab, where it is
called Get & Transform Data. There’s no need to install anything separately in that case.
However, if you’re using Excel 2010 or Excel 2013, Power Query does not come pre-
installed. You will need to download and install it manually as an add-in. This chapter will
guide you through the steps to do that.
Before downloading Power Query, you need to find out whether your Excel is 32-bit or 64-
bit.
• Open Excel.
• Click on the File tab.
• Go to Account (or Help in some versions).
• Click on About Excel.
• A window will appear showing whether your version is 32-bit or 64-bit.
Make a note of this. You’ll need it when choosing which file to download.
You should now see a new Power Query tab in your Excel ribbon.
Sometimes, even after installing, the Power Query tab doesn’t appear automatically. You’ll
need to activate it manually:
• Open Excel.
• Go to the File tab → Options.
• In the Excel Options dialog, click Add-Ins.
• At the bottom, in the Manage drop-down, choose COM Add-ins and click Go.
• In the list, check the box for Microsoft Power Query for Excel.
• Click OK, then restart Excel.
Now the Power Query tab should be visible and ready to use.
If you're comparing the Power Query add-in with the built-in Get & Transform in Excel
2016 and later, the core features are very similar. The main difference is where the options
appear—they may be placed in slightly different tabs or groups. However, the functionality
is almost the same, so you can follow the same steps regardless of your version.
Even if you're using Excel 2010 or 2013, you'll still be able to work through all the exercises
in this course or book without any problems.
Chapter 3: Overview of Query Editor in Power Query
Introduction to Power Query Editor in Excel
In Excel 2016 and later, Power Query is integrated under the Data tab and labeled as Get &
Transform. However, in Excel 2010 and 2013, it must be installed as an add-in, after which
it appears as a separate Power Query tab.
o Excel workbooks
o Text/CSV files
o XML or JSON files
o Databases
o Web sources
o Online services
o Blank queries
Note: While the UI elements and exact placement of these options may change in
future Excel updates, the core functionalities remain the same.
• From Text/CSV
• From Web
• From Table/Range
These options can also be accessed via the File and Other Sources sections within the Get
Data dropdown.
• Recent Sources: View and access your most recently used data connections.
• Existing Connections: Reuse previously connected datasets.
• Queries & Connections Pane: View all active queries and data connections in the
current workbook.
Launching the Query Editor
When data is loaded from a source (e.g., CSV or Excel), it appears in the central pane of the
Query Editor for manipulation.
The Query Editor contains a ribbon similar to Excel, with the following key tabs:
1. File
2. Home
3. Transform
4. Add Column
• Toggle display of the Formula Bar, Query Settings, and Advanced Editor.
Located on the right-hand side, the Query Settings pane is critical to working with Power
Query:
Important: Power Query acts like a step recorder, capturing each transformation. This
makes your process automatable. Once steps are defined, simply updating the source and
refreshing the query will apply the same transformations to the new data.
• Go to File → Close & Load to load the transformed data into Excel.
• Alternatively, you can discard changes if no transformation was done.
Chapter 4 - Import Data from TEXT Files in Excel using Power Query
Power Query in Excel makes importing data from text files both efficient and dynamic.
Before Power Query existed, importing text file data required manually opening the file and
walking through the Text Import Wizard every time. This method had to be repeated with
each new data file—making recurring data analysis repetitive and error-prone.
1. Go to File > Open > Browse and locate the text file (e.g., Sales Data March).
2. Excel would launch the Text Import Wizard, prompting you to select delimiters, data
formats, etc.
3. After import, any data transformations—like splitting or formatting—had to be
done manually in Excel.
4. These transformations would need to be repeated each time new monthly data
arrived.
Power Query eliminates the need to repeat steps by allowing data transformation to be
saved and reused.
• Power Query automatically applies steps such as promoting headers and changing
data types.
• You can modify or delete these applied steps as needed.
If the Product ID contains a string like PR001, and you want only the numeric part:
1. Double-click the query name in the Queries pane to reopen Power Query Editor.
2. In the Source step, change the file path from Sales Data March to Sales Data April.
3. Click OK.
4. Power Query re-applies all previous transformation steps automatically to the new
file.
5. Click Close & Load to refresh the table in Excel.
In this Chapter, you’ll learn how to import data from a CSV file into Excel using Power
Query, apply basic transformations, and set up automatic refresh whenever the source file
is updated. This helps you save time and keep your data analysis clean and consistent.
A preview window will open showing the first 200 rows of your data. This helps you
confirm the structure and delimiter (usually commas for CSV files).
Instead of loading the data directly into Excel, let’s clean it up first.
Let’s say the Product Id column contains both letters and numbers (e.g., “PR001”, “TX45”).
We want to remove the letters and keep only the numbers.
Here’s how to do it:
Delete the column with letters, and rename the other to “Product Id”.
🔹 Step 5: Reuse the Same Process for Other Files (Like April Data)
If your data is updated every month (e.g., Sales Data - [Link]), you don’t have to repeat all
the steps.
If the data inside your connected CSV file changes (e.g., updated sales values), just:
Power Query will go back to the CSV file, reapply the steps, and update the table instantly.
Bonus Tip
To avoid breaking the link, don’t move or rename the source CSV file after connecting it
with Power Query.
Chapter 6: Import Data from Another Excel Workbook Using Power Query
Power Query makes it easy to pull data from one Excel file into another. Instead of copy-
pasting data manually every time, Power Query lets you connect the files. Once
connected, any updates made in the original file can automatically reflect in your current
workbook with just a click.
🔹 Scenario
• A file called Sales Data - March [Link] that contains your raw data.
• A new workbook where you want to bring in that data automatically.
You’ll learn how to bring in this data, clean it if needed, and set it up to update easily when
changes are made in the original file.
1. Open a new or existing workbook (the one where you want to import the data).
2. Go to the Data tab.
3. Click on Get Data → From File → From Workbook.
4. Browse to find the file (e.g., Sales Data - March [Link]) and click Import.
A Navigator window will open, showing available objects like worksheets or tables from
the selected file.
- Sheet1
If the data source is not in a table format, it may include extra rows like titles or blank rows.
Let’s fix that.
Click on Sheet1 (or your specific sheet name) to preview the data.
- Title rows
- Blank rows
- Incorrect headers
The cleaned data will appear in Excel as a table. The name of the table will match the name
of the query (which you can change).
If you make a change in the original Excel file (e.g., changing names or values), you don’t
need to re-import.
Power Query will re-import the data, apply the same cleaning steps, and update your table.
If the data in the source file is already formatted as a table, Power Query can skip some
cleaning steps.
To create a table:
Let’s say the original sales file is updated with new staff names:
In this lesson, you’ll learn how to import data from within your current Excel workbook into
Power Query using three different methods:
Power Query helps you clean, reshape, and prepare data efficiently. But before you can
use it, your data must be brought into the Power Query Editor — and how you structure
your data in Excel affects this process.
• Date
• Product
• Category
• Quantity Sold
• Unit Price
• Total Revenue
Case 1: Importing from Plain Data (Sheet1)
When your data is just plain tabular data (not formatted as a table or named range), Power
Query will ask you to convert it into an Excel Table before importing.
Steps:
1. Go to Data tab.
2. Click From Table/Range.
3. Excel will ask to convert the data to a table. Click OK.
4. Power Query will open, and your data appears with default table name (e.g., Table2).
Note:
• Power Query detects column headers and assigns the right data types (e.g., Date,
Text, Number).
• This method is helpful, but you must format the data as a table first.
If your data is already formatted as a Table in Excel, importing it into Power Query is even
easier.
Steps:
Note:
You can also use a Named Range (a selected set of cells you’ve given a name, e.g.,
SalesData) to load data into Power Query.
Steps:
Key Differences:
Note:
• You may need to manually promote the header row and assign correct data types.
Best Practice
For most cases, using an Excel Table is the recommended way to bring data into Power
Query:
In this lesson, you will learn how to combine multiple Excel tables (from different sheets)
into one single table using Power Query's Append feature. This method is very useful
when you regularly receive similar data (e.g., monthly sales from different regions) and
want to avoid copying and pasting manually every time.
Scenario
• East
• West
• North
• South
Each sheet contains sales data for March 2024, formatted as Excel Tables.
Your task is to combine all four tables into one consolidated table using Power Query.
Once set up, you’ll only need to refresh the data when new data is added each month.
Step-by-Step Instructions
Step 1: Load Each Table into Power Query
Since each table doesn't indicate its region inside the data, you should add a new column to
label the region.
Repeat this step for each table, using the appropriate region name (West, North, or South).
Repeat this for all four regions. Now, all tables are stored as connections, not visible in the
workbook but ready for use.
Now let’s combine (append) all the connections into one table.
The combined data opens in Power Query Editor. You will now see all rows from each
region, with a new Region column showing where each record came from.
Optional: Tidy Up
You can do all this inside the Query Editor before loading the final result.
Step 5: Load the Combined Table to Excel
You now have one combined table with data from all regions.
1. Paste the new records in the corresponding regional sheets (e.g., East, West, etc.).
2. Go to your combined data sheet.
3. Click Refresh.
Power Query will update the consolidated report with the new entries — no manual
copying or pasting needed.
All tables must have the same column headers and column order.
For example, if one table uses Sale Date and another uses Date, Power Query will throw
an error.
Once headers are consistent, the append will work without errors.
Chapter 9: Combine Excel Tables in the Same Workbook Using Power Query
(Formula Method)
This method is ideal when all your data is stored in separate tables within the same file.
Instead of importing files or using the Append Queries method, we will use a Power Query
formula to identify and consolidate tables efficiently.
Scenario Example
You have sales data for four regions: East, West, North, and South. Each region's data is
stored in a separate table named East_Data, West_Data, North_Data, and South_Data.
Your goal is to combine these into a single table.
Step-by-Step Guide
=[Link]()
o Press Enter.
o This formula retrieves all named ranges, tables, and connections in the
current workbook.
4. Identify the Tables
o A table will appear with columns like Name and Content.
o The Name column contains the names of the tables (e.g., East_Data).
o The Content column holds the actual table data.
5. Filter Only the Required Tables
o Click the dropdown in the Name column.
o Choose Text Filters > Ends With and enter _Data.
o This ensures only the tables you want (e.g., East_Data, West_Data) are
included.
6. Combine the Tables
o Click the double-arrow icon (⇄) at the top of the Content column.
o Uncheck Use original column name as prefix.
o Click OK.
7. Clean the Region Names
o You now have a Name column (e.g., East_Data).
o Right-click the column > Replace Values.
o Replace _Data with an empty string to get clean region names.
o Rename the column to Region.
8. Set Data Types
o Ensure each column has the correct data type:
▪ Date column: Date
▪ Sales Rep, Item: Text
▪ Quantity, Price: Whole Number
▪ Commission: Decimal Number or Percentage
9. Load the Data
o Go to Home > Close & Load.
o This loads the combined table into a new worksheet.
If you don’t filter the _Data tables first, Power Query might include the newly created
combined table (Query1) in future refreshes. This causes recursion, leading to data
duplication.
To prevent this:
• Always filter by table name (e.g., only include names ending with _Data).
• Use consistent naming conventions for all source tables.
Summary
This approach is perfect for course materials, reporting dashboards, and regular business
processes involving recurring data layouts.
Chapter 10: Combine Tables from Different Workbooks into One Table Using
Power Query
In this lesson, you’ll learn how to combine data from different Excel workbooks into a single
table using Power Query. This is helpful when you receive similar data from multiple
sources (e.g., branches, departments, or regions) in separate files and want to consolidate
them all into one report.
Scenario Example
You receive monthly sales data from four regions: East, West, North, and South. Each region
sends in its own Excel file containing a table with sales information.
Your goal is to combine these four files into one single table using Power Query.
Step-by-Step Instructions
Step 1: Set Up Your Workbook
This creates a query connection without loading the data into the worksheet.
Before loading:
• Check that columns like Name, Product, and Region are Text.
• Check that numeric columns like Quantity or Sales are Whole Number or Decimal
Number.
• Change any incorrect data types from the column header dropdown.
You’ll now see all your data from the four regions combined into one Excel table.
Refreshing with New Monthly Data
1. In the Power Query Editor, open the query for that region (e.g., East).
2. Click the gear icon next to the Source step.
3. Browse to the new file location and select the new file.
4. Click OK to update the source.
• Automation: Easily update the full report when new data comes in.
• Consistency: Structure remains the same every month.
• Scalability: Add more regions or files without rebuilding your report.
• No VBA or coding required.
This method is especially useful in organizations where reports are compiled monthly from
multiple branches or departments. Power Query keeps your workflow clean, organized, and
easily refreshable.