Power Query in Excel
Power Query in Excel
Complete Guide
https://www.simplilearn.com/
tutorials/excel-tutorial/power-
query-in-excel
see also
https://www.ablebits.com/office-
addins-blog/excel-join-tables-
power-query/
https://www.ablebits.com/office-
addins-blog/excel-merge-tables-
matching-columns/#Combine-
Sheets-Wizard
https://www.ablebits.com/office-
addins-blog/compare-two-excel-
files-sheets/
By Shruti M
Share This Article:
Last updated on Feb 16, 2024287153
How to join tables in Excel: Power Query
vs. Merge Tables Wizard
https://www.ablebits.com/office-addins-blog/excel-join-tables-power-query/#import-merged-table-
to-Excel
pitia pia
Power Query makes solving common data tasks easy. A lot of precious
time is usually spent on repetitive manual work such as cut & paste tasks
or combining columns and applying filters. The Power Query tool makes it
a whole lot easier to perform such tasks.
An added benefit here is that Power Query is easy to use when compared
to other BI tools. The Power Query interface is user-friendly. Since it is
very similar to the Excel interface, many users will find it comfortable.
As the name suggests, Power Query is the most powerful data automation
tool found in Excel 2010 and later. Power Query allows a user to import
data into Excel through external sources, such as Text files, CSV files,
Web, or Excel workbooks, to list a few. The data can then be cleaned and
prepared for our requirements.
Power Query has several useful features embedded in it, such as the
appending of data and creating relationships between different data sets.
This is called the merging of the data sets. We can also group and
summarize data with the help of the tool. Needless to say, it is a very
useful tool.
On clicking the Download button, a dialog box opens where you can
choose the appropriate download option that suits your OS. Power Query
will then be downloaded on your system.
It is a built-in tool starting with Excel 2016 and is available in the Get &
Transforms Data Section under Data Tab.
1. Connect
In this phase, users connect to the data source(s) from which they want to
extract data. Power Query supports many data sources, including
databases, files, web pages, and more. Users can also specify any
required authentication or authorization details during this phase.
2. Transform
Once the data is loaded into Power Query, users can use various data
transformation tools to clean, reshape, and transform the data to meet
their specific needs. Common data transformation tasks include removing
duplicates, filtering data, merging data, splitting columns, and pivoting
data.
3. Combine
Power Query also allows users to combine data from multiple sources
using various techniques. Users can merge tables, append, or join data
using a common key. This phase is beneficial for integrating data from
different sources into a single, unified view.
4. Load
Finally, in the Load phase, users specify where to load the transformed
data. They can load the data into an Excel worksheet or a Power BI report
or create a connection to the data source so that the data is automatically
refreshed whenever the source data changes.
Data Preview:
Applied Steps
Formula Bar
The Formula Bar in Power Query is a section within the Power Query Editor
that allows users to view and edit the formulas associated with each step
or transformation. It provides a text-based representation of the applied
transformations, enabling users to manually input or modify the
underlying M language code that defines the data transformations. The
Formula Bar offers a more advanced and precise way to manipulate data
by leveraging the full capabilities of the M language. It is particularly
useful for complex or custom transformations that cannot be achieved
through the graphical user interface alone.
1. Get Data
Importing data is easy with the help of the Get & Transform Data section
of the Data tab in Excel.
From Files: Excel files(Workbook), Text or CSV files, XML files, and
JSON files.
From Databases: SQL Server, Microsoft Access, SQL Server Analysis
Services.
From Other Sources: Excel Tables/ Ranges, Web, Microsoft Query,
OData feeds.
2. Transform Data
After importing the data, we can transform it with the help of Power
Query. The Power Query Editor helps you transform data based on your
needs.
Let’s take a look at the editor and understand its different components.
The six main sections of the Power Query Editor are as follows:
Query Editor Ribbon: This ribbon is similar to the one on the Excel
interface. Various commands are organized in separate tabs.
Query List: This section lets you browse through a list of all queries
in your current workbook.
Formula Bar: The current transformation’s formula will be specified
here in the M language.
Data Preview: You can see the preview of your data based on the
current transformation step. You can access various transformation
commands by right-clicking on the column header or by clicking on
the respective column header's filter option.
Properties: This section consists of a list of query steps. Here, you
will be able to name your query. Naming a query is an important
step to identify a query easily.
Applied steps: Each transformation step you take will be recorded
here in chronological order. You can add, remove, edit, or reorder
the steps if required.
This was all about the editor interface. Now, let’s proceed by
understanding a simple transformation example on the Editor.
Follow the steps below to learn how to sort a table based on a single
column.
On clicking OK, the table gets sorted based on the ‘Name’ column
alphabetically.
You will see the M code in the formula bar. This is used to record the steps
applied.
The applied transformations will reflect in the ‘Applied Steps’
section.
3. Output to Excel
After performing all the operations on the editor, we will have to output it
to our Excel sheet. To do this, click on the Close and Load option on the
Ribbon section of the Power Query Editor.
On clicking this option, the Editor closes and loads the result to your
worksheet.
In the next section, we will look at different ways by which we can Import
Data to our Excel sheet.
Click on the Data tab --> Get Data command. This opens up a drop-
down menu. The drop-down menu offers different options for us to
import our data. To import from the Excel workbook, we select the
option ‘From File’ and then ‘From Workbook’.
Excel opens up a dialog box that helps us navigate and select the
workbook.
Once we have navigated to the workbook location, we can click on it
and then click ‘Open’.
This opens up the navigation dialog box. The navigation dialog box
gives you a set of data sources.
From here, we can select the data on which we want to work.
Finally, click on ‘Load’ to import the data.
So, these were a few techniques by which you can import data to Excel.
Going ahead, let’s look at a simple demo on how you can Import Data
from a CSV file.
In this section, you will learn how to format text in Uppercase, Lowercase,
and understand how to use the Trim operation.
UPPERCASE
Step 1: Load the required data onto the Power Query Editor. This can be
done by selecting the respective data source from the Get & Transform
Data section of the Excel Data tab. This will open up the Editor, which
allows us to edit the data.
Step 2: Click on the column name and then go to the “Transform” tab,
which will display a variety of options. Clicking on the option to Format
text will open up a drop-down menu with a text edit option of
‘UPPERCASE’.
Step 3: Finally, on selecting the UPPERCASE edit option, all the text in the
given column will be converted to uppercase.
LOWERCASE
Step 1: Load the required data onto the Power Query Editor. This can be
done by selecting the respective data source from the Get & Transform
Data section of the Excel data tab. This will open up the Editor, which
allows us to edit the data.
Step 2: Click on the column name and then go to the ‘Transform’ tab,
which will display a variety of options. Clicking on the option to Format
text will open up a drop-down menu with a text edit option of
‘LOWERCASE’.
Step 3: As you can see, all the text from the selected column will be
converted to lowercase.
TRIM
Step 1: Load the required data onto the Power Query Editor. This can be
done by selecting the respective data source from the Get & Transform
Data section of the Excel data tab. This will open up the Power Query
Editor, which allows us to edit the data.
Step 2:To remove all the extra white spaces from the data, click on the
column name, and then select the ‘Transform’ tab, displaying various
options. Clicking on the ‘Format’ option will display a drop-down menu
with a text edit option called ‘Trim’.
Step 3: Finally, on selecting the Trim edit option, all the extra white
spaces in the given column will be removed.
Step 2: To split the column with the help of a delimiter from the data, click
on the ‘Transform’ tab followed by the ‘Split column’ option. This will
display a drop-down menu with an option to split the data By Delimiter.
Step 3: A dialog box appears where you can select a delimiter. Then click
on OK.
Step 4: Now, we can see that the data is split into two columns concerning
the delimiter.
3. Transpose a Data Table
Step 1: Load the required data onto the Power Query Editor. This can be
done by selecting the respective data source from the Get & Transform
Data section of the Excel data tab. This will open up the Editor, which
allows us to edit the data.
Step 1: Load the required data onto the Power Query Editor. This can be
done by selecting the respective data source from the Get & Transform
Data section of the Excel data tab. This will open up the Editor, which
allows us to edit the data.
Step 3: As you can notice, the data is now free from duplicates. To save
the updated table without duplicate rows, go to the Home tab and click on
‘Close and Load’.
Combine Queries
Power Query has two different options that help us combine different
datasets. The two options are:
Append
Merge
APPEND
In Power Query, the append operation creates a new table by joining all
the rows from the first query, followed by all rows from the second query.
Follow the steps below to understand how to perform an Append
operation.
Step 1:
Firstly, we have to load the data into the Excel workbook. In this
demonstration, you will learn how to Append data from a CSV file.
This can be done by selecting the Data tab, followed by the
‘Text/CSV File’ command.
Once we have selected the option, an Import Data dialog box opens.
Select the desired CSV file and click on import.
A dialog box opens, which shows a preview of the data contained.
Clicking on ‘Load’ will enter the data in a new sheet.
Continue this step to add the required data into new sheets.
MERGE
The Merge option is similar to the JOIN function in SQL. Merge is a way of
combining two existing queries and creating a new query.
Step 1:
Firstly, we have to load the data into the Excel workbook. In this
example, we will demonstrate how to Merge data from a CSV file.
This can be done by clicking on the Data tab, followed by the
‘Text/CSV File’ command.
Once we have selected the option, an Import Data dialog box
opens.
Select the desired CSV file and click on import.
A dialog box opens, which shows a preview of the data contained.
Clicking on ‘Load’ will enter the data in a new sheet.
Continue this step to add all the required datasets to be merged into
different sheets.
Step 5: The merged data is now loaded onto our Excel worksheet.
This was all about combining the queries using Merge and Append
operations.
Key Pointers
The Queries & Connections Window:
The Queries & Connections window is a central hub in Power Query where
you manage and interact with your data queries and connections. It
provides a clear overview of all the queries in your workbook, allowing you
to navigate, edit, and refresh them easily. Additionally, the window
displays the connections to external data sources, enabling you to modify
connection properties, update credentials, or create new connections. The
Queries & Connections window is a powerful tool for organizing and
controlling your data connections and queries in Excel.
In Power Query, the Transform and Add Column tabs are two key sections
that facilitate data manipulation. The Transform tab offers a wide range of
data transformation options, allowing you to perform actions such as
filtering rows, sorting data, removing duplicates, and splitting columns. On
the other hand, the Add Column tab focuses specifically on adding new
calculated columns to your data. It provides access to various functions,
operators, and formulas that can be used to create custom columns based
on existing data. Understanding the distinction between these two tabs
helps you effectively manipulate and enhance your data in Power Query.
The File tab in Power Query provides options for managing queries and
connections at the workbook level. From this tab, you can create new
queries, import data from external sources, export queries to other
workbooks, or load queries from a query repository. Additionally, the File
tab allows you to access the Options menu, where you can configure
various Power Query settings, such as privacy levels, global query
settings, and regional preferences. The File tab serves as a gateway to
essential file and configuration-related functionalities in Power Query.
The Home tab in Power Query is the central hub for common data
manipulation tasks. It offers a set of frequently used operations, including
filtering, sorting, grouping, removing columns, and transforming data
types. This tab also provides options to manage query settings, such as
refreshing queries, viewing query dependencies, and accessing query
properties. The Home tab serves as a convenient starting point for most
data transformation activities, allowing you to quickly perform common
tasks and navigate to other sections of Power Query.
The Add Column tab in Power Query is dedicated to enhancing your data
by creating new calculated columns. It offers a variety of functions,
operators, and formulas that you can use to define custom calculations
based on existing data. From basic arithmetic operations to advanced text
manipulation, date calculations, and conditional logic, the Add Column tab
provides a wide range of tools to transform your data and derive
additional insights. This tab enables you to extend the capabilities of your
data model and tailor it to your specific analysis requirements.
The View tab in Power Query provides options to customize the visual
appearance and layout of the Power Query Editor window. It allows you to
change the zoom level, toggle the Formula Bar display, show or hide
gridlines, and adjust the column widths. The View tab also offers options
to enable or disable the Formula Bar autocomplete feature and configure
the display of formula errors. These customization options help improve
the overall user experience and make working with Power Query more
efficient.
In Power Query, you have the ability to export connections, which allows
you to share or reuse them across multiple workbooks. Exporting
connections enables you to package the connection details, including the
data source, authentication credentials, and connection settings, into a
file that can be imported into another workbook. This feature is
particularly valuable when you want to replicate the same connections in
different workbooks or when you need to share connections with
colleagues or clients. By exporting connections, you simplify the process
of establishing data connections and ensure consistency across your data
analysis projects.
Conclusion
In this article, you have learned how to load data using Power Query,
perform transformations, and output the data back to your Excel
worksheet. Using the Power Query tool, you are saving loads of time by
performing numerous functions just with the help of a few clicks!
If you have any questions for us, please feel free to mention them in the
comments section of this Power Query article, and we’ll have our experts
answer it for you right away.
FAQs
1. What is an Excel Power Query?
Power Query is built into Excel 2016 and later versions but may need to
be activated sometimes. To activate it, users can go to the "File" menu,
select "Options," and then choose "Add-ins." They can then select "COM
Add-ins" and enable "Microsoft Power Query for Excel."
To create a Power Query in Excel, go to the Data tab, click on the Get
Data button, select the data source, specify import options, apply
transformations in the Power Query Editor, and load the data back to the
worksheet.
Duratio
Program Name Fees
n
Professional Certificate Program in Business Analytics &
11 $
Generative AI
Months 2,290
Cohort Starts: 1 May, 2024
Post Graduate Program in Data Analytics $
8 Months
Cohort Starts: 6 May, 2024 2,790
Applied AI & Data Science $
3 Months
Cohort Starts: 14 May, 2024 1,999
Post Graduate Program in Data Science 11 $
Cohort Starts: 28 May, 2024 Months 2,461
Duratio
Program Name Fees
n
Caltech Post Graduate Program in Data Science 11 $
Cohort Starts: 29 May, 2024 Months 2,461
11 $
Data Scientist
Months 1,069
View All
Recommended Reads
10 May, 2023
Software Development
24 Jan, 2020
Software Development
C++ Power
prevNext
9 months
View Program
Business Analyst
11 months
View Program